From: Ilia Alshanetsky Date: Tue, 21 Feb 2006 15:35:01 +0000 (+0000) Subject: MFH: Fixed bug #36458 (sleep() accepts negative values). X-Git-Tag: php-4.4.3RC1~54 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a03b57390ee046a35599f53e15bf2bf4bc6e799;p=php MFH: Fixed bug #36458 (sleep() accepts negative values). --- diff --git a/NEWS b/NEWS index fd1a508f5e..4f24b79704 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ PHP 4 NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2006, Version 4.4.3 - Added a check for special characters in the session name. (Ilia) +- Fixed bug #36458 (sleep() accepts negative values). (Ilia) - Fixed bug #36242 (Possible memory corruption in stream_select()). (Tony) - Fixed bug #36223 (curl bypasses open_basedir restrictions). (Tony) - Fixed bug #36205 (Memory leaks on duplicate cookies). (Dmitry) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index c849091419..87f64da232 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1662,14 +1662,16 @@ PHP_FUNCTION(flush) Delay for a given number of seconds */ PHP_FUNCTION(sleep) { - pval **num; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + long num; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + RETURN_FALSE; } - - convert_to_long_ex(num); - php_sleep(Z_LVAL_PP(num)); + if (num < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of seconds must be greater than or equal to 0"); + RETURN_FALSE; + } + php_sleep(num); } /* }}} */ @@ -1678,13 +1680,16 @@ PHP_FUNCTION(sleep) PHP_FUNCTION(usleep) { #if HAVE_USLEEP - pval **num; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + long num; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + RETURN_FALSE; + } + if (num < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of microseconds must be greater than or equal to 0"); + RETURN_FALSE; } - convert_to_long_ex(num); - usleep(Z_LVAL_PP(num)); + usleep(num); #endif } /* }}} */