diff options
author | Jeremy Allison <jra@samba.org> | 2006-11-07 02:33:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:42 -0500 |
commit | ea705fb3453a94fb4fee6f3a5299c988d8e48b26 (patch) | |
tree | d807bf28fadcf922653280da64981e1ef0cd64d5 /source3 | |
parent | 482603735d97b6de5ae06decf118ec8ea8c1961c (diff) | |
download | samba-ea705fb3453a94fb4fee6f3a5299c988d8e48b26.tar.gz samba-ea705fb3453a94fb4fee6f3a5299c988d8e48b26.tar.bz2 samba-ea705fb3453a94fb4fee6f3a5299c988d8e48b26.zip |
r19601: Fix protection from invalid struct tm values.
Backport from Samba4.
Jeremy.
(This used to be commit 02a0ac0bacafe91e4fa3ca0cae2f05a25215efbc)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/replace/timegm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source3/lib/replace/timegm.c b/source3/lib/replace/timegm.c index 8db9bb4e09..395c684e11 100644 --- a/source3/lib/replace/timegm.c +++ b/source3/lib/replace/timegm.c @@ -51,6 +51,16 @@ time_t rep_timegm(struct tm *tm) {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_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; |