Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] sigsegv
On Sat, 2023-04-29 at 10:52 +0000, Sebastian Gniazdowski wrote:
> It says "incomplete sequence \339" although egrep $'\330' ~/.zhistory
> doesn't return anything…
So it looks like this is probably confusion over bad or incomplete
multibyte characters again.
Rather than bufferwords() --- I think that's not relevant at this point
--- this could be the code that reads a history line back into the buffer
and divides it into words getting confused. This is different from
the code that adds to a history line when it's first generated and
likely to be less accurate --- and also fits better with the
reproducibility of this problem.
Anyway, given there's no single place where the line originates,
and given that we're probably not going to be able to turn it into
a proper line if the there's not a complete character sequence,
safety at the point in question is probably the best we've got.
See if this helps.
pws
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 96a211c69..2067f5bab 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -1233,9 +1233,16 @@ histwgetfn(UNUSED(Param pm))
pushnode(l, getdata(n));
while (he) {
+ char *hstr = he->node.nam;
+ int len = strlen(hstr);
for (iw = he->nwords - 1; iw >= 0; iw--) {
- h = he->node.nam + he->words[iw * 2];
- e = he->node.nam + he->words[iw * 2 + 1];
+ int wbegin = he->words[iw * 2];
+ int wend = he->words[iw * 2 + 1];
+
+ if (wbegin >= len || wend > len)
+ break;
+ h = hstr + wbegin;
+ e = hstr + wend;
sav = *e;
*e = '\0';
addlinknode(l, dupstring(h));
Messages sorted by:
Reverse Date,
Date,
Thread,
Author