[PATCH] Ensure mktime sets errno on error (bug 23789)

Albert ARIBAUD albert.aribaud@3adev.fr
Fri Oct 26 16:28:00 GMT 2018


Hi Paul,

On Thu, 25 Oct 2018 12:49:49 -0700, Paul Eggert <eggert@cs.ucla.edu>
wrote :

> On 10/25/18 9:57 AM, Albert ARIBAUD wrote:
> > - To distinguish 'old' vs proper errno from __tz_set(), we would need
> >    it to return e.g. an int equal to 0 for success and -1 for failure,
> >    so that mktime() could detect __tz_set() failure and return -1 while
> >    preserving errno.  
> 
> This sounds like the way to go. The other approach that you mentioned 
> (saving and restoring errno a couple of times) would be more 
> error-prone, particularly in non-glibc environments (remember, this code 
> is shared with Gnulib).

[ s/__tz_set/__tzset/g ]

Problem: __tzset is aliased by tzset, which has a public prototype of
'void (*) (void)'.

I'm worried that for some architectures at least, existing userland
object code which calls tzset() might, if run above a glibc featuring
the change above, actually call __tz_set(), bypassing the wrapper and
potentially trashing some register(s) with the return value from
__tzset().

If there is such a risk, then the solution is to keep tzset() an alias
of __tzset(), keep __tzset() a 'void (*) (void)' as it is now, and
introduce another function, e.g. ___tzset(), which would be the 'int
(*) (void)', and replace the call to __tzset() within mktime() et al.
with a call to ___tzset() along with proper return value handling.

Comments/thoughts?

Cordialement,
Albert ARIBAUD
3ADEV



More information about the Libc-alpha mailing list