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

Re: PATCH: ztrftime: Handle all non-zsh format chars with strftime if present (v2)



On Thu, Jul 9, 2015 at 7:43 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jul 9,  6:31am, Mikael Magnusson wrote:
> }
> } > +               while (*fmt && strchr("OE^#_-0123456789", *fmt++));
> } > +               if (*fmt++)
> } > +                   goto strftimehandling;
> } > +           }
> } >             switch (*fmt++) {
> }
> } Okay, fun thinko here, should be
> } -               while (*fmt && strchr("OE^#_-0123456789", *fmt++));
> } +               while (*fmt && strchr("OE^#_-0123456789", *fmt))
> } +                   fmt++;
>
> Isn't there still a thinko there?  In the event that the "while" loop
> terminates because *fmt == 0, the subsequent "if (*fmt++)" will still
> increment fmt past the end of the string, and then "switch (*fmt++)"
> becomes an invalid dereference.
>
> Or is that eventuality already prevented by the surrounding code?  I
> haven't been applying these patches and still haven't seen the whole
> thing in one diff.

No, I think you're right. However, I can't get it to fail with my
current code either. It seems better to do the fmt++ only in the true
case though.

-- 
Mikael Magnusson



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