From 32efc76c327fc8e968a34b327f7ce5b2e205070e Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 16 Apr 2024 14:08:28 +0200 Subject: [PATCH 1/4] Use return value of getpwuid_r(), not errno (#13969) --- ext/posix/posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index e5ab4b5940a..dbc888a7ea6 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -952,7 +952,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; From f6e8145b475f0b39046dd081372e5335acf5e174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 16 Apr 2024 14:13:36 +0200 Subject: [PATCH 2/4] fix: zend-max-execution-timers with negative or high timeout value (#13942) Align the behavior of zend-max-execution-timers with other timeout impls: Negative or very high timeout values are equivalent to no timeout --- Zend/zend_execute_API.c | 5 +++++ Zend/zend_max_execution_timer.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index fa5e13dba2e..0e2ff263c9a 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1518,6 +1518,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; From d47aaacf3caf7f4adcf9f651a081187644b0ad2d Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 16 Apr 2024 14:18:48 +0200 Subject: [PATCH 3/4] [ci skip] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index f9664526c9a..cfb310512a8 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS handlers when JIT is enabled). (Bob) . Fixed bug GH-13931 (Applying zero offset to null pointer in Zend/zend_opcode.c). (nielsdos) + . Fixed bug GH-13942 (Align the behavior of zend-max-execution-timers with + other timeout implementations). (Kévin Dunglas) - Fibers: . Fixed bug GH-13903 (ASAN false positive underflow when executing copy()). From 812d19d67ecdf13c234d527ed5365d15a7ec6c75 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 16 Apr 2024 14:20:05 +0200 Subject: [PATCH 4/4] [ci skip] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 2027ebcc5d9..83ce8c08a96 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ PHP NEWS handlers when JIT is enabled). (Bob) . Fixed bug GH-13931 (Applying zero offset to null pointer in Zend/zend_opcode.c). (nielsdos) + . Fixed bug GH-13942 (Align the behavior of zend-max-execution-timers with + other timeout implementations). (Kévin Dunglas) - Fibers: . Fixed bug GH-13903 (ASAN false positive underflow when executing copy()).