diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-10-18 22:33:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:21:26 -0500 |
commit | d04efb30a013c3c9061f62081fc6fc020bbbd7b0 (patch) | |
tree | dcb4ddb96732afc9361c4e71f8594ac8df5fc9cf | |
parent | 4b9eee02c4a0c856f16d9f17929e726fb75e051f (diff) | |
download | samba-d04efb30a013c3c9061f62081fc6fc020bbbd7b0.tar.gz samba-d04efb30a013c3c9061f62081fc6fc020bbbd7b0.tar.bz2 samba-d04efb30a013c3c9061f62081fc6fc020bbbd7b0.zip |
r19403: try to fix the crashes in the buildfarm related to timegm
(This used to be commit c4e1d2c5ae11acac7dd2cedca411b9b6be84962f)
-rw-r--r-- | source4/lib/replace/timegm.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index ff90626d44..608882d0ce 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -44,13 +44,22 @@ static int is_leap(unsigned y) return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); } -time_t timegm(struct tm *tm) +time_t rep_timegm(struct tm *tm) { static const unsigned ndays[2][12] ={ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; time_t res = 0; unsigned i; + + if (tm->tm_mon > 12 || + 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; |