Fixed bug #60222 (time_nanosleep() does validate input params).

This commit is contained in:
Ilia Alshanetsky 2012-03-12 16:53:07 +00:00
parent 438a30f1e7
commit 7337a901b7
2 changed files with 24 additions and 0 deletions

View file

@ -4467,6 +4467,15 @@ PHP_FUNCTION(time_nanosleep)
return; 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_sec = (time_t) tv_sec;
php_req.tv_nsec = tv_nsec; php_req.tv_nsec = tv_nsec;
if (!nanosleep(&php_req, &php_rem)) { if (!nanosleep(&php_req, &php_rem)) {

View 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===