From: Ilia Alshanetsky Date: Mon, 12 Mar 2012 16:53:07 +0000 (+0000) Subject: Fixed bug #60222 (time_nanosleep() does validate input params). X-Git-Tag: php-5.5.0alpha1~439 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7337a901b78f792ef2f18d0bf807ec505dec57f0;p=php Fixed bug #60222 (time_nanosleep() does validate input params). --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index c036ad9fc8..528e4f65b9 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4467,6 +4467,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)) { diff --git a/ext/standard/tests/time/bug60222.phpt b/ext/standard/tests/time/bug60222.phpt new file mode 100644 index 0000000000..8053a81dea --- /dev/null +++ b/ext/standard/tests/time/bug60222.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #60222 (time_nanosleep() does validate input params) +--FILE-- + +===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===