summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-03-21 20:05:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-03-21 20:05:42 -0700
commitfc9f466a57cff429e65d73aba353f36e977866cd (patch)
treea44c3916f21a547185b828d95d455bc6e72e31f9 /stdlib
parent705aafca215d6bf7b289f443fdebc4681776cf28 (diff)
downloadtxr-fc9f466a57cff429e65d73aba353f36e977866cd.tar.gz
txr-fc9f466a57cff429e65d73aba353f36e977866cd.tar.bz2
txr-fc9f466a57cff429e65d73aba353f36e977866cd.zip
time: crash: glibc overwrites time zone with literal
A crash occurs in the make_time_impl function whereby the mktime or timegm function invoked via the pmktime(&local) call overwrites the TIME_ZONE field with a string literal. We dynamically allocated that string and expect to free it in the time_fields_cleanup function. The solution is to wrap the struct tm structure with a container which separately tracks that pointer and frees that copy of it. * time.c (struct tm_wrap): New struct type. (time_fields_to_tm): Take a pointer to struct tm_wrap instead of struct_tm, and stash the timezone string in the wrapper. (time_fields_cleanup): Take a a pointer to struct tm_wrap and free the stashed pointer in the container, which is immune to TM_ZONE being altered. (time_struct_to_tm): Take pointer to tm_wrap because this calls time_fields_to_tm. (make_time_impl, time_string_meth, time_parse_meth): Use struct tm_wrap instead of struct tm.
Diffstat (limited to 'stdlib')
0 files changed, 0 insertions, 0 deletions