From: Antony Dovgal Date: Thu, 16 Feb 2006 10:13:23 +0000 (+0000) Subject: improve usleep(): use new param parsing API, check for negative values X-Git-Tag: RELEASE_1_2~193 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=77b7b56ab08205ed72eb62780f06de5766078e48;p=php improve usleep(): use new param parsing API, check for negative values (related to #36410) --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 2fb179c7b0..02114c8da1 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1770,13 +1770,16 @@ PHP_FUNCTION(sleep) PHP_FUNCTION(usleep) { #if HAVE_USLEEP - zval **num; + long num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; } - convert_to_long_ex(num); - usleep(Z_LVAL_PP(num)); + if (num < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of microseconds must be greater than or equal to 0"); + RETURN_FALSE; + } + usleep(num); #endif } /* }}} */