aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcal.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-11-22 22:23:58 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-11-22 22:58:04 +0100
commite269f09438ad1bfaef044c5781615cba45ab7690 (patch)
treec68bd062390f59525ae5cf061c131f52a513d1b7 /src/pcal.c
parent6b6067a53bd6e78215f4c39cc0d9fa2258b6e095 (diff)
downloadcalcurse-e269f09438ad1bfaef044c5781615cba45ab7690.tar.gz
calcurse-e269f09438ad1bfaef044c5781615cba45ab7690.zip
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>
Diffstat (limited to 'src/pcal.c')
-rw-r--r--src/pcal.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pcal.c b/src/pcal.c
index c4f731d..4c00ddc 100644
--- a/src/pcal.c
+++ b/src/pcal.c
@@ -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);
lt.tm_hour = lt.tm_min = lt.tm_sec = 0;
lt.tm_isdst = -1;
date = mktime(&lt);