commit 7bce846309e1a010300b5990555ff67d035fbf10
parent 81300f52b0404d93e6123f8dc6de235c005b18e2
Author: Naveen Narayanan <zerous@simple-cc.org>
Date: Thu, 1 Oct 2020 16:15:55 +0200
libc: Fix bug in mktime.c
tm_year should never be negative.
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/libc/time/mktime.c b/src/libc/time/mktime.c
@@ -42,6 +42,9 @@ normalize(struct tm *tm)
return 0;
}
+ if (tm->tm_year < 0)
+ return 0;
+
day = tm->tm_mday;
yday = 0;
year = 1900 + tm->tm_year;
@@ -49,7 +52,7 @@ normalize(struct tm *tm)
for (mon = tm->tm_mon; day < 1; --mon) {
if (mon == JAN) {
- if (year == EPOCH)
+ if (year == 1900)
return 0;
year--;
_daysmon[FEB] = FEBDAYS(year);