diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-03-21 20:05:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-03-21 20:05:42 -0700 |
commit | fc9f466a57cff429e65d73aba353f36e977866cd (patch) | |
tree | a44c3916f21a547185b828d95d455bc6e72e31f9 /stdlib | |
parent | 705aafca215d6bf7b289f443fdebc4681776cf28 (diff) | |
download | txr-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