check bounds before casting (long long) to time_t

This commit is contained in:
Brent Cook 2015-10-21 22:17:13 -05:00
parent 959241fe88
commit 3f79a49dd2

View File

@ -208,6 +208,12 @@ time_t timegm(struct tm *tm)
errno = EOVERFLOW;
return -1;
}
#if SIZEOF_TIME_T != 8
if (t > (long long)INT_MAX || t < (long long)INT_MIN) {
errno = EOVERFLOW;
return -1;
}
#endif
*tm = new;
tm->tm_isdst = 0;
return t;