Prevent FreeBSD's strftime from segfaulting by setting tm_zone.
This commit is contained in:
parent
fe6a9db1e5
commit
5e3f793326
10
scsh/time1.c
10
scsh/time1.c
|
@ -322,7 +322,7 @@ s48_value date2time(s48_value sec, s48_value min, s48_value hour,
|
|||
s48_value format_date(s48_value sch_fmt, s48_value sch_sec, s48_value sch_min,
|
||||
s48_value sch_hour, s48_value sch_mday,
|
||||
s48_value sch_month, s48_value sch_year,
|
||||
s48_value tz, s48_value sch_summer,
|
||||
s48_value sch_tz, s48_value sch_summer,
|
||||
s48_value sch_week_day, s48_value sch_year_day)
|
||||
{
|
||||
struct tm d;
|
||||
|
@ -349,6 +349,10 @@ s48_value format_date(s48_value sch_fmt, s48_value sch_sec, s48_value sch_min,
|
|||
d.tm_yday = s48_extract_fixnum(sch_year_day);
|
||||
d.tm_isdst = (S48_EQ_P (sch_summer, S48_FALSE)) ? 0 : 1;
|
||||
|
||||
#ifdef HAVE_TM_ZONE
|
||||
d.tm_zone = s48_extract_string(sch_tz); /* FreeBSD's strftime reads this */
|
||||
#endif
|
||||
|
||||
/* Copy fmt -> fmt2, converting ~ escape codes to % escape codes.
|
||||
** Set zone=1 if fmt has a ~Z.
|
||||
** Build up an estimate of how large the target buffer needs to be.
|
||||
|
@ -404,8 +408,8 @@ s48_value format_date(s48_value sch_fmt, s48_value sch_sec, s48_value sch_min,
|
|||
*q++ = 'x'; *q = '\0'; /* Append the guard "x" suffix and nul-terminate. */
|
||||
|
||||
/* Fix up the time-zone if it is being used and the user passed one in. */
|
||||
if( zone && S48_STRING_P(tz) ) {
|
||||
oldenv = make_newenv(tz, newenv);
|
||||
if( zone && S48_STRING_P(sch_tz) ) {
|
||||
oldenv = make_newenv(sch_tz, newenv);
|
||||
if( !oldenv ) {
|
||||
int err = errno;
|
||||
Free(fmt);
|
||||
|
|
Loading…
Reference in New Issue