svn commit: samba r19602 - in branches: SAMBA_3_0_23/source/lib
SAMBA_3_0_24/source/lib
jra at samba.org
jra at samba.org
Tue Nov 7 02:35:59 GMT 2006
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;
More information about the samba-cvs
mailing list