From 7337a901b78f792ef2f18d0bf807ec505dec57f0 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 12 Mar 2012 16:53:07 +0000 Subject: [PATCH] Fixed bug #60222 (time_nanosleep() does validate input params). --- ext/standard/basic_functions.c | 9 +++++++++ ext/standard/tests/time/bug60222.phpt | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 ext/standard/tests/time/bug60222.phpt 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=== -- 2.40.0