mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fixed bug #60222 (time_nanosleep() does validate input params).
This commit is contained in:
parent
943a4fed4e
commit
9c886ea553
1
NEWS
1
NEWS
@ -24,6 +24,7 @@ PHP NEWS
|
||||
. Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia)
|
||||
. Fixed bug #60227 (header() cannot detect the multi-line header with CR).
|
||||
(rui, Gustavo)
|
||||
. Fixed bug #60222 (time_nanosleep() does validate input params). (Ilia)
|
||||
. Fixed bug #52719 (array_walk_recursive crashes if third param of the
|
||||
function is by reference). (Nikita Popov)
|
||||
. Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry)
|
||||
|
@ -4497,6 +4497,15 @@ PHP_FUNCTION(time_nanosleep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (tv_sec < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds value must be greater than 0");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (tv_nsec < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The nanoseconds value must be greater than 0");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_req.tv_sec = (time_t) tv_sec;
|
||||
php_req.tv_nsec = tv_nsec;
|
||||
if (!nanosleep(&php_req, &php_rem)) {
|
||||
|
15
ext/standard/tests/time/bug60222.phpt
Normal file
15
ext/standard/tests/time/bug60222.phpt
Normal file
@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #60222 (time_nanosleep() does validate input params)
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(time_nanosleep(-1, 0));
|
||||
var_dump(time_nanosleep(0, -1));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Warning: time_nanosleep(): The seconds value must be greater than 0 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: time_nanosleep(): The nanoseconds value must be greater than 0 in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user