File php-5.3.8-CVE-2011-1466.patch of Package php5.openSUSE_12.1_Update

http://svn.php.net/viewvc/?view=revision&revision=306475
http://svn.php.net/viewvc/?view=revision&revision=317360
http://svn.php.net/viewvc/?view=revision&revision=317387

Index: ext/calendar/gregor.c
===================================================================
--- ext/calendar/gregor.c.orig
+++ ext/calendar/gregor.c
@@ -127,6 +127,7 @@
  **************************************************************************/
 
 #include "sdncal.h"
+#include <limits.h>
 
 #define GREGOR_SDN_OFFSET         32045
 #define DAYS_PER_5_MONTHS  153
@@ -146,21 +147,12 @@ void SdnToGregorian(
 	long int temp;
 	int dayOfYear;
 
-	if (sdn <= 0) {
-		*pYear = 0;
-		*pMonth = 0;
-		*pDay = 0;
-		return;
+	if (sdn <= 0 ||
+			sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
+		goto fail;
 	}
 	temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
 
-	if (temp < 0) {
-		*pYear = 0;
-		*pMonth = 0;
-		*pDay = 0;
-		return;
-	}
-
 	/* Calculate the century (year/100). */
 	century = temp / DAYS_PER_400_YEARS;
 
@@ -190,6 +182,11 @@ void SdnToGregorian(
 	*pYear = year;
 	*pMonth = month;
 	*pDay = day;
+	return;
+fail:
+	*pYear = 0;
+	*pMonth = 0;
+	*pDay = 0;
 }
 
 long int GregorianToSdn(
openSUSE Build Service is sponsored by