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 | 02a0ac0bacafe91e4fa3ca0cae2f05a25215efbc (patch) | |
tree | 5c4105f9f559f27632d08902e804789df85d1b13 /source | |
parent | 68fc15a5e025348dee4bf14aa4498e20905cb377 (diff) | |
download | samba-02a0ac0bacafe91e4fa3ca0cae2f05a25215efbc.tar.gz samba-02a0ac0bacafe91e4fa3ca0cae2f05a25215efbc.tar.xz samba-02a0ac0bacafe91e4fa3ca0cae2f05a25215efbc.zip |
r19601: Fix protection from invalid struct tm values.
Backport from Samba4.
Jeremy.
Diffstat (limited to 'source')
-rw-r--r-- | source/lib/replace/timegm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/lib/replace/timegm.c b/source/lib/replace/timegm.c index 8db9bb4e09f..395c684e117 100644 --- a/source/lib/replace/timegm.c +++ b/source/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; |