[Privoxy-devel] more time questions

Fabian Keil fk at fabiankeil.de
Thu May 5 08:25:59 UTC 2016


Lee <ler762 at gmail.com> wrote:

> On 5/3/16, Fabian Keil <fk at fabiankeil.de> wrote:
> > Lee <ler762 at gmail.com> wrote:
> >  
> >> Right now I'm feeling like I can't read code :(   What's the expected
> >> behavior if --enable-strptime-sanity-checks is configured & this bit
> >> is added to regression-tests.action after
> >> {+hide-if-modified-since{-60} -crunch-if-none-match}
> >> # Set Header    = If-Modified-Since: Gee, this date is invalid
> >> # Expect Header = REMOVAL
> >>
> >> # Set Header    = If-Modified-Since: Monday, 01-Jan-2025 00:15:00 GMT
> >> # Expect Header = SOME CHANGE
> >> # Set Header    = If-Modified-Since: wednesday, 01-Jan-2025 00:15:00 GMT
> >> # Expect Header = SOME CHANGE
> >>
> >> 1/1/2025 can't be both Mon & Wed so shouldn't one of them cause a
> >> complaint?  
> >
> > The strptime() sanity check merely confirms that parsing a date format
> > generated from a time_t results in the same time_t again.
> >
> > This happens after the original date has been parsed. If strptime()
> > silently ignores incorrect weekdays the expected behaviour is therefore
> > that the check does not detect this.  
> 
> OK.  Not a whole lot of error checking going on, so that explains
> that.  Thank you.
> 
> Next set of questions is
> - does timegm in miscutil.c leak memory on non-windows systems?
> 
>       old_zone = malloc(3 + strlen(zone) + 1);
>          ...
> #ifdef _WIN32
>          free(old_zone);
> #endif /* def _WIN32 */
> 
> Seems like the code should be doing a free regardless of _WIN32 being
> defined or not.

POSIX-compliant putenv() implementations add the buffer directly to
the environment in which case freeing it while it's in use results in
memory corruption.

Windows duplicates the buffer content but I'm not aware of other
platforms that do this that also rely on the fallback timegm().

> - is there a timing window in miscutil.c timegm that can change TZ to "UTC"?
> 
> Unless each thread get it's own copy of environment variables, it
> seems like one thread can do
[...]
> and then the other thread does the putenv / tzset and TZ is
> permanently changed to UTC.

I agree that this could happen. The function can probably also
temporarily affect timestamps used for log messages.

You could try triggering the issues with Privoxy-Regression-Test's
--fork option.

Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.privoxy.org/pipermail/privoxy-devel/attachments/20160505/d1771103/attachment.bin>


More information about the Privoxy-devel mailing list