summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2012-03-12 16:53:07 +0000
committerIlia Alshanetsky <iliaa@php.net>2012-03-12 16:53:07 +0000
commit9c886ea553d2f7bbfa545046b1b8a01d5390d092 (patch)
tree17eca290bc737c9b9b0a0a077ad2fb8d6250bc56 /ext
parent943a4fed4e1a799e6a8f98de61c48b972ed00837 (diff)
downloadphp-git-9c886ea553d2f7bbfa545046b1b8a01d5390d092.tar.gz
Fixed bug #60222 (time_nanosleep() does validate input params).
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/basic_functions.c9
-rw-r--r--ext/standard/tests/time/bug60222.phpt15
2 files changed, 24 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 91ec37b32c..99831a1f42 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -4497,6 +4497,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--
+<?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===