Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] sigsegv



Adding wend<0 to the break-if helps for the crash:
+           if (wbegin >= len || wend > len||wend<0)
+               break;

 Pressing Alt-/ at empty line yields:

16:52[*cal/share/zinit/plugins/zsh]1# !
   (git)-[master●]
zsh: do you wish to see all 1048 possibilities (1080 lines)?

I wonder if 1080 is a much less value than the maximum? Why ! appears
after Alt-/ ? I'm confused if it limits the results?

On Wed, 3 May 2023 at 15:35, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> The error occurs with patch. I've played around in gdb:
>
> (gdb) p (int)(e-hstr)
> $65 = -31903
>
> This should be positive – e points to a \0 inserted in hstr. That's
> why printing e shows unexpected values. How come wend became negative?
>
> On Sun, 30 Apr 2023 at 17:31, Peter Stephenson
> <p.w.stephenson@xxxxxxxxxxxx> wrote:
> >
> > 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));
> >
> >
>
>
> --
> Best regards,
> Sebastian Gniazdowski



-- 
Best regards,
Sebastian Gniazdowski




Messages sorted by: Reverse Date, Date, Thread, Author