1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-08 04:58:40 +03:00

r19601: Fix protection from invalid struct tm values.

Backport from Samba4.
Jeremy.
(This used to be commit 02a0ac0bacafe91e4fa3ca0cae2f05a25215efbc)
This commit is contained in:
Jeremy Allison 2006-11-07 02:33:10 +00:00 committed by Gerald (Jerry) Carter
parent 482603735d
commit ea705fb345

View File

@ -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;