iliaa Mon, 12 Mar 2012 16:53:07 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=324163
Log: Fixed bug #60222 (time_nanosleep() does validate input params). Bug: https://bugs.php.net/60222 (Open) time_nanosleep won't throw a warning for negative second Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c A php/php-src/branches/PHP_5_3/ext/standard/tests/time/bug60222.phpt U php/php-src/branches/PHP_5_4/NEWS U php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c A php/php-src/branches/PHP_5_4/ext/standard/tests/time/bug60222.phpt U php/php-src/trunk/ext/standard/basic_functions.c A php/php-src/trunk/ext/standard/tests/time/bug60222.phpt Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2012-03-12 16:19:10 UTC (rev 324162) +++ php/php-src/branches/PHP_5_3/NEWS 2012-03-12 16:53:07 UTC (rev 324163) @@ -24,6 +24,7 @@ . Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia) . Fixed bug #60227 (header() cannot detect the multi-line header with CR). (rui, Gustavo) + . Fixed bug #60222 (time_nanosleep() does validate input params). (Ilia) . Fixed bug #52719 (array_walk_recursive crashes if third param of the function is by reference). (Nikita Popov) . Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry) Modified: php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c 2012-03-12 16:19:10 UTC (rev 324162) +++ php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c 2012-03-12 16:53:07 UTC (rev 324163) @@ -4497,6 +4497,15 @@ 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)) { Added: php/php-src/branches/PHP_5_3/ext/standard/tests/time/bug60222.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/time/bug60222.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/time/bug60222.phpt 2012-03-12 16:53:07 UTC (rev 324163) @@ -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=== Modified: php/php-src/branches/PHP_5_4/NEWS =================================================================== --- php/php-src/branches/PHP_5_4/NEWS 2012-03-12 16:19:10 UTC (rev 324162) +++ php/php-src/branches/PHP_5_4/NEWS 2012-03-12 16:53:07 UTC (rev 324163) @@ -87,6 +87,7 @@ - Standard: . Fixed memory leak in substr_replace. (Pierrick) . Make max_file_uploads ini directive settable outside of php.ini (Rasmus) + . Fixed bug #60222 (time_nanosleep() does validate input params). (Ilia) . Fixed bug #60106 (stream_socket_server silently truncates long unix socket paths). (Ilia) Modified: php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c =================================================================== --- php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c 2012-03-12 16:19:10 UTC (rev 324162) +++ php/php-src/branches/PHP_5_4/ext/standard/basic_functions.c 2012-03-12 16:53:07 UTC (rev 324163) @@ -4432,6 +4432,15 @@ 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)) { Added: php/php-src/branches/PHP_5_4/ext/standard/tests/time/bug60222.phpt =================================================================== --- php/php-src/branches/PHP_5_4/ext/standard/tests/time/bug60222.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/ext/standard/tests/time/bug60222.phpt 2012-03-12 16:53:07 UTC (rev 324163) @@ -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=== Property changes on: php/php-src/branches/PHP_5_4/ext/standard/tests/time/bug60222.phpt ___________________________________________________________________ Added: svn:executable + * Modified: php/php-src/trunk/ext/standard/basic_functions.c =================================================================== --- php/php-src/trunk/ext/standard/basic_functions.c 2012-03-12 16:19:10 UTC (rev 324162) +++ php/php-src/trunk/ext/standard/basic_functions.c 2012-03-12 16:53:07 UTC (rev 324163) @@ -4467,6 +4467,15 @@ 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)) { Added: php/php-src/trunk/ext/standard/tests/time/bug60222.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/time/bug60222.phpt (rev 0) +++ php/php-src/trunk/ext/standard/tests/time/bug60222.phpt 2012-03-12 16:53:07 UTC (rev 324163) @@ -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===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php