Fixed crash and improved signal validation

This commit is contained in:
Ilia Alshanetsky 2011-06-03 17:18:46 +00:00
parent 2b22017e8f
commit 2dce38f598
2 changed files with 10 additions and 6 deletions

View File

@ -849,6 +849,11 @@ PHP_FUNCTION(pcntl_signal)
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 @@ PHP_FUNCTION(pcntl_signal)
}
/* 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;

View File

@ -28,12 +28,10 @@ Warning: pcntl_signal() expects at least 2 parameters, 0 given in %s
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