summaryrefslogtreecommitdiffstats
path: root/stdlib/compiler.tl
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
commit83ab5e338faa99fcb4b0f507d1f90fd4b6cf3f1b (patch)
treea44c3916f21a547185b828d95d455bc6e72e31f9 /stdlib/compiler.tl
parentc1028a70340c82d9c1143da195ae31b1eba927c7 (diff)
downloadtxr-83ab5e338faa99fcb4b0f507d1f90fd4b6cf3f1b.tar.gz
txr-83ab5e338faa99fcb4b0f507d1f90fd4b6cf3f1b.tar.bz2
txr-83ab5e338faa99fcb4b0f507d1f90fd4b6cf3f1b.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/compiler.tl')
0 files changed, 0 insertions, 0 deletions