Author: jra Date: 2006-11-07 02:35:58 +0000 (Tue, 07 Nov 2006) New Revision: 19602
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19602 Log: Fix protection from invalid struct tm values. Backport from Samba4. Jeremy. Modified: branches/SAMBA_3_0_23/source/lib/timegm.c branches/SAMBA_3_0_24/source/lib/timegm.c Changeset: Modified: branches/SAMBA_3_0_23/source/lib/timegm.c =================================================================== --- branches/SAMBA_3_0_23/source/lib/timegm.c 2006-11-07 02:33:10 UTC (rev 19601) +++ branches/SAMBA_3_0_23/source/lib/timegm.c 2006-11-07 02:35:58 UTC (rev 19602) @@ -53,6 +53,16 @@ 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; Modified: branches/SAMBA_3_0_24/source/lib/timegm.c =================================================================== --- branches/SAMBA_3_0_24/source/lib/timegm.c 2006-11-07 02:33:10 UTC (rev 19601) +++ branches/SAMBA_3_0_24/source/lib/timegm.c 2006-11-07 02:35:58 UTC (rev 19602) @@ -53,6 +53,16 @@ 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;