Replace localtime() with localtime_r()
Since the result of localtime() is stored in a statically allocated structure, data was overwritten when a context switch occurred during (or shortly after) the execution of localtime(), potentially resulting in critical data corruption. BUG#7 and BUG#8 are likely related. This patch converts all usages of localtime() with localtime_r(), which is thread-safe. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Reported-by: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
@@ -64,7 +64,7 @@ foreach_date_dump(const long date_end, struct rpt *rpt, llist_t * exc,
|
||||
time_t t;
|
||||
|
||||
t = item_first_date;
|
||||
lt = *localtime(&t);
|
||||
localtime_r(&t, <);
|
||||
lt.tm_hour = lt.tm_min = lt.tm_sec = 0;
|
||||
lt.tm_isdst = -1;
|
||||
date = mktime(<);
|
||||
|
||||
Reference in New Issue
Block a user