ref: c4abae030242ab0d8ca7e13fd4d6fcb2440b544b
parent: 0663aab4168efce2a70f907b7d723c1c85122c27
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Apr 25 05:50:32 EDT 2019
[libc] Initiliaze tz before use in localtime() Tz was used before being initialized. The more generic solution is to call _tzone with the timep received, and let to the implementation of _tzone to decide how to use that parameter or to ignore it.
--- a/src/libc/time/asctime.c
+++ b/src/libc/time/asctime.c
@@ -1,7 +1,6 @@
#include <time.h>
#undef asctime
-#include <stdio.h> // TODO: remove me!
char *
asctime(const struct tm *tm)
{
--- a/src/libc/time/localtime.c
+++ b/src/libc/time/localtime.c
@@ -10,10 +10,10 @@
struct tm *tm;
time_t t = *timep;
+ tz = _tzone(gmtime(timep));
t += tz->gmtoff * 60;
t += tz->isdst * 60;
tm = gmtime(&t);
- tz = _tzone(tm);
tm->tm_zone = tz->name;
tm->tm_isdst = tz->isdst;
tm->tm_gmtoff = tz->gmtoff;