mirror of
https://github.com/php/php-src.git
synced 2024-11-30 13:25:43 +08:00
Fix GH-16454: Unhandled INF in date_sunset() with tiny $utcOffset
After normalization, `N` is supposed to be in range [0, 24], but for very large and very small `$utcOffset` this is not necessarily the case, since the normalization might yied `-inf` or `inf`. If that happens, we let the function fail silently, since it is highly unlikely that such `$utcOffset`s are passed in practice. Closes GH-16483.
This commit is contained in:
parent
41af9335b7
commit
9bc34182b6
4
NEWS
4
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)
|
||||
|
@ -5140,6 +5140,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:
|
||||
|
21
ext/date/tests/gh16454.phpt
Normal file
21
ext/date/tests/gh16454.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset)
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(date_sunrise(0, SUNFUNCS_RET_STRING, 61, -150, 90, PHP_FLOAT_MAX));
|
||||
var_dump(date_sunrise(0, SUNFUNCS_RET_STRING, 61, -150, 90, -PHP_FLOAT_MAX));
|
||||
var_dump(date_sunset(0, SUNFUNCS_RET_STRING, 61, -150, 90, PHP_FLOAT_MAX));
|
||||
var_dump(date_sunset(0, SUNFUNCS_RET_STRING, 61, -150, 90, -PHP_FLOAT_MAX));
|
||||
?>
|
||||
--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)
|
Loading…
Reference in New Issue
Block a user