diff options
author | Brent Cook <bcook@openbsd.org> | 2015-10-21 22:17:13 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2015-10-21 22:17:13 -0500 |
commit | 3f79a49dd29be1ea2a227304a496269711eea4d9 (patch) | |
tree | e03fbed9beec9dcc0cf1855daae927cfa09171a5 | |
parent | 959241fe887812502d586d02be070db96dd98864 (diff) | |
download | portable-3f79a49dd29be1ea2a227304a496269711eea4d9.tar.gz portable-3f79a49dd29be1ea2a227304a496269711eea4d9.tar.bz2 portable-3f79a49dd29be1ea2a227304a496269711eea4d9.zip |
check bounds before casting (long long) to time_t
-rw-r--r-- | crypto/compat/timegm.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/compat/timegm.c b/crypto/compat/timegm.c index 5a9e600..2658445 100644 --- a/crypto/compat/timegm.c +++ b/crypto/compat/timegm.c | |||
@@ -208,6 +208,12 @@ time_t timegm(struct tm *tm) | |||
208 | errno = EOVERFLOW; | 208 | errno = EOVERFLOW; |
209 | return -1; | 209 | return -1; |
210 | } | 210 | } |
211 | #if SIZEOF_TIME_T != 8 | ||
212 | if (t > (long long)INT_MAX || t < (long long)INT_MIN) { | ||
213 | errno = EOVERFLOW; | ||
214 | return -1; | ||
215 | } | ||
216 | #endif | ||
211 | *tm = new; | 217 | *tm = new; |
212 | tm->tm_isdst = 0; | 218 | tm->tm_isdst = 0; |
213 | return t; | 219 | return t; |