diff --git a/NEWS b/NEWS index d5cd09f0639..3eb9779fde9 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,10 @@ PHP NEWS . Fixed bug GH-16359 (crash with curl_setopt* CURLOPT_WRITEFUNCTION without null callback). (David Carlier) +- 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 3293e1ad599..bf5e9834d99 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5555,6 +5555,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..e3a35a1ba19 --- /dev/null +++ b/ext/date/tests/gh16454.phpt @@ -0,0 +1,29 @@ +--TEST-- +GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset) +--FILE-- + +--EXPECTF-- +Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d + +Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d +bool(false) + +Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d + +Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d +bool(false) + +Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d + +Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d +bool(false) + +Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d + +Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d +bool(false)