iliaa Fri, 03 Jun 2011 17:18:46 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=311781
Log:
Fixed crash and improved signal validation
Changed paths:
U php/php-src/trunk/ext/pcntl/pcntl.c
U php/php-src/trunk/ext/pcntl/tests/pcntl_signal.phpt
Modified: php/php-src/trunk/ext/pcntl/pcntl.c
===================================================================
--- php/php-src/trunk/ext/pcntl/pcntl.c 2011-06-03 17:12:59 UTC (rev 311780)
+++ php/php-src/trunk/ext/pcntl/pcntl.c 2011-06-03 17:18:46 UTC (rev 311781)
@@ -849,6 +849,11 @@
return;
}
+ if (signo < 1 || signo > 32) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid signal");
+ RETURN_FALSE;
+ }
+
if (!PCNTL_G(spares)) {
/* since calling malloc() from within a signal handler is not
portable,
* pre-allocate a few records for recording signals */
@@ -863,9 +868,10 @@
}
/* Special long value case for SIG_DFL and SIG_IGN */
- if (Z_TYPE_P(handle)==IS_LONG) {
- if (Z_LVAL_P(handle)!= (long) SIG_DFL && Z_LVAL_P(handle) !=
(long) SIG_IGN) {
+ if (Z_TYPE_P(handle) == IS_LONG) {
+ if (Z_LVAL_P(handle) != (long) SIG_DFL && Z_LVAL_P(handle) !=
(long) SIG_IGN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid
value for handle argument specified");
+ RETURN_FALSE;
}
if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), (int)
restart_syscalls) == SIG_ERR) {
PCNTL_G(last_error) = errno;
Modified: php/php-src/trunk/ext/pcntl/tests/pcntl_signal.phpt
===================================================================
--- php/php-src/trunk/ext/pcntl/tests/pcntl_signal.phpt 2011-06-03 17:12:59 UTC
(rev 311780)
+++ php/php-src/trunk/ext/pcntl/tests/pcntl_signal.phpt 2011-06-03 17:18:46 UTC
(rev 311781)
@@ -28,12 +28,10 @@
NULL
bool(true)
-Warning: pcntl_signal(): Invalid value for handle argument specified in %s
-
-Warning: pcntl_signal(): Error assigning signal %s
+Warning: pcntl_signal(): Invalid signal %s
bool(false)
-Warning: pcntl_signal(): Error assigning signal %s
+Warning: pcntl_signal(): Invalid signal %s
bool(false)
Warning: pcntl_signal(): not callable is not a callable function name error in
%s
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php