summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/timegm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/lib/timegm.c b/source/lib/timegm.c
index 0e42a863d3f..dcc710b1ece 100644
--- a/source/lib/timegm.c
+++ b/source/lib/timegm.c
@@ -53,6 +53,16 @@ time_t timegm(struct tm *tm)
time_t res = 0;
unsigned i;
+ if (tm->tm_mon > 12 ||
+ tm->tm_mon < 0 ||
+ tm->tm_mday > 31 ||
+ tm->tm_min > 60 ||
+ tm->tm_sec > 60 ||
+ tm->tm_hour > 24) {
+ /* invalid tm structure */
+ return 0;
+ }
+
for (i = 70; i < tm->tm_year; ++i)
res += is_leap(i) ? 366 : 365;