[PATCH] add tests for tzset(3)

Jeff Johnston jjohnstn@redhat.com
Mon May 16 17:49:18 GMT 2022


Hello, thanks for looking at it.  I forgot to increase the name buffers by
1 and pass 11 to the sscanf.  This will
make the max test trigger when needed.

I have included a new patch.

-- Jeff J.


On Thu, May 12, 2022 at 2:36 PM jdoubleu <hi@jdoubleu.de> wrote:

> Hi Jeff,
>
> I finally found some time to have a look at your patch.
> >       if (sscanf (tzenv, "%10[-+0-9A-Za-z]%n", __tzname_std, &n) <= 0
> >               || n < TZNAME_MIN || TZNAME_MAX < n || '>' != tzenv[n])
>
> > +      else if (n < TZNAME_MIN || TZNAME_MAX < n)
>
> I think the sub-expression "TZNAME_MAX < n" can never be true, can it?
> sscanf will always stop after 10 characters.
>
> What do you think about including the TZNAME_MAX macro inside the format
> string?
>
> > #define STR(s) #s
> > #define STR_LIT(s) STR(s)
> > ...
> > sscanf(tzenv, "%" STR_LIT(TZNAME_MAX) "[-+0-9A-Za-z]%n", __tzname_dst,
> &n)
>
> I'll try to update the tests in the coming days, so I can verify your
> changes work as expected.
>
>
> Cheers
> ---
> 🙎🏻‍♂️ jdoubleu
> On 4/29/2022 5:46 PM, Jeff Johnston wrote:
> > I have revised my tzset_r.c patch so that the tzrules are initialized so
> we
> > don't inherit the previous settings if not specified for a particular TZ.
> > As well, I defaulted them if TZ is not specified.
> >
> > -- Jeff J.
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Modify-tzset_r.c-to-handle-errors.patch
Type: text/x-patch
Size: 5926 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20220516/abfbd997/attachment-0001.bin>


More information about the Newlib mailing list