From 1b8cfaf23dc6c2e89f502bdc3e9da7e5abb2488b Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Mon, 19 Jan 2015 21:31:15 +1100 Subject: [PATCH 1/2] Fix integer overflow in calender. Fix int overflows in conversation functions for calendar. Add tests for the overflows. --- ext/calendar/calendar.c | 2 +- ext/calendar/gregor.c | 2 +- ext/calendar/julian.c | 2 +- ext/calendar/tests/gregoriantojd_overflow.phpt | 10 ++++++++++ ext/calendar/tests/juliantojd_overflow.phpt | 10 ++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 ext/calendar/tests/gregoriantojd_overflow.phpt create mode 100644 ext/calendar/tests/juliantojd_overflow.phpt diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index 40ae249cdab..47f2c1dd543 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -12,7 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Shane Caraveo | + | Authors: Shane Caraveo | | Colin Viebrock | | Hartmut Holzgraefe | | Wez Furlong | diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c index 069fe6eb5ae..4c91fa8d540 100644 --- a/ext/calendar/gregor.c +++ b/ext/calendar/gregor.c @@ -195,7 +195,7 @@ zend_long GregorianToSdn( int inputMonth, int inputDay) { - int year; + zend_long year; int month; /* check for invalid dates */ diff --git a/ext/calendar/julian.c b/ext/calendar/julian.c index 904727ff042..6ab0854c3be 100644 --- a/ext/calendar/julian.c +++ b/ext/calendar/julian.c @@ -217,7 +217,7 @@ zend_long JulianToSdn( int inputMonth, int inputDay) { - int year; + zend_long year; int month; /* check for invalid dates */ diff --git a/ext/calendar/tests/gregoriantojd_overflow.phpt b/ext/calendar/tests/gregoriantojd_overflow.phpt new file mode 100644 index 00000000000..a189cc80c35 --- /dev/null +++ b/ext/calendar/tests/gregoriantojd_overflow.phpt @@ -0,0 +1,10 @@ +--TEST-- +gregoriantojd() +--SKIPIF-- + +--FILE-- + +--EXPECT-- +2193176185 diff --git a/ext/calendar/tests/juliantojd_overflow.phpt b/ext/calendar/tests/juliantojd_overflow.phpt new file mode 100644 index 00000000000..f2f5aa182d0 --- /dev/null +++ b/ext/calendar/tests/juliantojd_overflow.phpt @@ -0,0 +1,10 @@ +--TEST-- +juliantojd() +--SKIPIF-- + +--FILE-- + +--EXPECT-- +622764916319 From d2b03119e23a5230cce39a721fd53eecf725507b Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Sat, 12 Nov 2016 17:35:04 +0000 Subject: [PATCH 2/2] news entry for calendar overflow fix --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 1dd3dda4db5..22e1bfa4d44 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2016 PHP 7.0.14 +- Calendar: + . Fix integer overflows (Joshua Rogers) + - Core: . Fixded bug #72736 (Slow performance when fetching large dataset with mysqli / PDO). (Dmitry)