From: Gustavo André dos Santos Lopes Date: Tue, 27 Sep 2011 10:57:25 +0000 (+0000) Subject: - Added tests and NEWS for r306475; see bug #55797. X-Git-Tag: php-5.5.0alpha1~1061 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a723eb69c800175797b48fa47a0c1059dd1d96a;p=php - Added tests and NEWS for r306475; see bug #55797. - Removed now redundant previous overflow check, which relied on undefined behavior (wraparound) and was ignored in optimized builds. --- diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c index cf9860366c..7e33d36c66 100644 --- a/ext/calendar/gregor.c +++ b/ext/calendar/gregor.c @@ -153,10 +153,6 @@ void SdnToGregorian( } temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1; - if (temp < 0) { - goto fail; - } - /* Calculate the century (year/100). */ century = temp / DAYS_PER_400_YEARS; diff --git a/ext/calendar/tests/bug55797_1.phpt b/ext/calendar/tests/bug55797_1.phpt new file mode 100644 index 0000000000..ffd617dfb7 --- /dev/null +++ b/ext/calendar/tests/bug55797_1.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #55797: Integer overflow in SdnToGregorian leads to segfault (in optimized builds) +--SKIPIF-- + +--FILE-- + + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(%d) + ["abbrevdayname"]=> + string(%d) "%s" + ["dayname"]=> + string(%d) "%s" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} + diff --git a/ext/calendar/tests/bug55797_2.phpt b/ext/calendar/tests/bug55797_2.phpt new file mode 100644 index 0000000000..2a9183dd8d --- /dev/null +++ b/ext/calendar/tests/bug55797_2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #55797: Integer overflow in SdnToGregorian leads to segfault (in optimized builds) +--SKIPIF-- + +--FILE-- + + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(%d) + ["abbrevdayname"]=> + string(%d) "%s" + ["dayname"]=> + string(%d) "%s" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} +