diff --git a/NEWS b/NEWS index ec9ce161f63..b06d52da789 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,10 @@ PHP NEWS . Fixed bug GH-16302 (CurlMultiHandle holds a reference to CurlHandle if curl_multi_add_handle fails). (timwolla) +- Date: + . Fixed bug GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset). + (cmb) + - DOM: . Fixed bug GH-16316 (DOMXPath breaks when not initialized properly). (nielsdos) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 3b456188aab..d8e7e96dfa6 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5328,6 +5328,9 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s if (N > 24 || N < 0) { N -= floor(N / 24) * 24; } + if (N > 24 || N < 0) { + RETURN_FALSE; + } switch (retformat) { case SUNFUNCS_RET_STRING: diff --git a/ext/date/tests/gh16454.phpt b/ext/date/tests/gh16454.phpt new file mode 100644 index 00000000000..3d57276ddf5 --- /dev/null +++ b/ext/date/tests/gh16454.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset) +--FILE-- + +--EXPECTF-- +Deprecated: Function date_sunrise() is deprecated in %s on line %d +bool(false) + +Deprecated: Function date_sunrise() is deprecated in %s on line %d +bool(false) + +Deprecated: Function date_sunset() is deprecated in %s on line %d +bool(false) + +Deprecated: Function date_sunset() is deprecated in %s on line %d +bool(false)