Fix race conditions involving setenv, gmtime, localtime, asctime.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 2 May 2012 23:25:46 +0000 (16:25 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 2 May 2012 23:25:46 +0000 (16:25 -0700)
commit7ed806a75c15de00d60ef37f347b5800370fb77c
tree544c50daa8065996076ab015e73788cc92ea0edf
parent99d2758343245de1ac452a9b8d1f4c1521f8c8d6
Fix race conditions involving setenv, gmtime, localtime, asctime.

Without this fix, interrupts could mess up code that uses these
nonreentrant functions, since setting TZ invalidates existing
tm_zone or tzname values, and since most of these functions return
pointers to static storage.
* editfns.c (format_time_string, Fdecode_time, Fencode_time)
(Fcurrent_time_string, Fcurrent_time_zone, Fset_time_zone_rule):
Grow the critical sections to include not just invoking
localtime/gmtime, but also accessing these functions' results
including their tm_zone values if any, and any related TZ setting.
(format_time_string): Last arg is now struct tm *, not struct tm **,
so that the struct tm is saved in the critical section.  All
callers changed.  Simplify allocation of initial buffer, partly
motivated by the fact that memory allocation needs to be outside
the critical section.
src/ChangeLog
src/editfns.c