diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index d2198ba2d11..28862525e65 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1540,6 +1540,11 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */ struct itimerval t_r; /* timeout requested */ int signo; + // Prevent EINVAL error + if (seconds < 0 || seconds > 999999999) { + seconds = 0; + } + if(seconds) { t_r.it_value.tv_sec = seconds; t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0; diff --git a/Zend/zend_max_execution_timer.c b/Zend/zend_max_execution_timer.c index 48a4d1bd664..f9f9740fd8a 100644 --- a/Zend/zend_max_execution_timer.c +++ b/Zend/zend_max_execution_timer.c @@ -71,6 +71,11 @@ void zend_max_execution_timer_settime(zend_long seconds) /* {{{ }*/ timer_t timer = EG(max_execution_timer_timer); + // Prevent EINVAL error + if (seconds < 0 || seconds > 999999999) { + seconds = 0; + } + struct itimerspec its; its.it_value.tv_sec = seconds; its.it_value.tv_nsec = its.it_interval.tv_sec = its.it_interval.tv_nsec = 0; diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 8b3c48131c8..ecbb8494087 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -1008,7 +1008,7 @@ PHP_FUNCTION(posix_getpwuid) try_again: err = getpwuid_r(uid, &_pw, pwbuf, pwbuflen, &retpwptr); if (err || retpwptr == NULL) { - if (errno == ERANGE) { + if (err == ERANGE) { pwbuflen *= 2; pwbuf = erealloc(pwbuf, pwbuflen); goto try_again;