]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #36458 (sleep() accepts negative values).
authorIlia Alshanetsky <iliaa@php.net>
Tue, 21 Feb 2006 15:35:01 +0000 (15:35 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 21 Feb 2006 15:35:01 +0000 (15:35 +0000)
NEWS
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index fd1a508f5e4489eccb62d1b3d657f9430aa82c3a..4f24b79704272f0b1ebe930cbed262dc89773a1d 100644 (file)
--- 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)
index c84909141924472c4d08f12ba8b43afcf7b28451..87f64da2325fe2183b002abca3000028be87fa8a 100644 (file)
@@ -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
 }
 /* }}} */