shithub: scc

Download patch

ref: 9c4c13bcccfc42136fe7650d0e905301268cb3f2
parent: 1c8ba5d798e7676ca4240e73db7fc36cbcfecdbb
author: Naveen Narayanan <[email protected]>
date: Thu Oct 1 12:15:55 EDT 2020

libc: Fix bug in mktime.c

tm_year should never be negative.

--- a/src/libc/time/mktime.c
+++ b/src/libc/time/mktime.c
@@ -42,6 +42,9 @@
 		return 0;
 	}
 
+	if (tm->tm_year < 0)
+		return 0;
+
 	day = tm->tm_mday;
 	yday = 0;
 	year = 1900 + tm->tm_year;
@@ -49,7 +52,7 @@
 
 	for (mon = tm->tm_mon; day < 1; --mon) {
 		if (mon == JAN) {
-			if (year == EPOCH)
+			if (year == 1900)
 				return 0;
 			year--;
 			_daysmon[FEB] = FEBDAYS(year);