diff options
Diffstat (limited to 'ext/calendar')
-rw-r--r-- | ext/calendar/jewish.c | 3 | ||||
-rw-r--r-- | ext/calendar/tests/jdtojewish64.phpt | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c index f4dc7c35a..fcc0e5c0b 100644 --- a/ext/calendar/jewish.c +++ b/ext/calendar/jewish.c @@ -272,6 +272,7 @@ #define HALAKIM_PER_METONIC_CYCLE (HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7)) #define JEWISH_SDN_OFFSET 347997 +#define JEWISH_SDN_MAX 324542846L /* 12/13/887605, greater value raises interger overflow */ #define NEW_MOON_OF_CREATION 31524 #define SUNDAY 0 @@ -519,7 +520,7 @@ void SdnToJewish( int tishri1After; int yearLength; - if (sdn <= JEWISH_SDN_OFFSET) { + if (sdn <= JEWISH_SDN_OFFSET || sdn > JEWISH_SDN_MAX) { *pYear = 0; *pMonth = 0; *pDay = 0; diff --git a/ext/calendar/tests/jdtojewish64.phpt b/ext/calendar/tests/jdtojewish64.phpt new file mode 100644 index 000000000..9f01109a7 --- /dev/null +++ b/ext/calendar/tests/jdtojewish64.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #64895: Integer overflow in SndToJewish +--SKIPIF-- +<?php +include 'skipif.inc'; +if (PHP_INT_SIZE == 4) { + die("skip this test is for 64bit platform only"); +} +?> +--FILE-- +<?php +$a = array(38245310, 324542846, 324542847, 9223372036854743639); + +foreach ($a as $x) var_dump(jdtojewish($x)); +--EXPECTF-- +string(11) "2/22/103759" +string(12) "12/13/887605" +string(5) "0/0/0" +string(5) "0/0/0" |