Subject: Re: standards/21722: ISO-C conforming use of struct tm can crash
To: Simon Burge <simonb@wasabisystems.com>
From: Richard Earnshaw <rearnsha@arm.com>
List: netbsd-bugs
Date: 05/30/2003 15:33:13
>
> > One `fix' would be to ignore (struct tm)->tm_zone when processing 'Z'
> > (ie, just remove the #ifdef TM_ZONE/#endif block in strftime.c) and use
> > only tzname[]. I think we can also use the timezone variable for 'z'
> > as well.
> >
> > I don't know if this is the best way to fix this problem :-)
> >
>
> There's already code in strftime.c to handle the case when TM_ZONE is not
> defined. Similarly for TM_GMTOFF. IMO we should be using that code
> instead of assuming that the non-standard fields have been filled in.
> Only interfaces that aren't part of ISO-C should be accessing the extended
> fields (strftime may also do so, but only when processing a modifier that
> isn't part of ISO C; neither %z nor %Z fall into that category).
Sorry, I've just realized that that is effectively what you wrote.
I should also qualify my other statement. I'm referring only to those
functions that read the extended fields. It's perfectly OK for ISO-C
interfaces to fill in the extended fields when they can (localtime, gmtime
etc).
R.