[php-src] PHP-8.2: fix: zend-max-execution-timers with negative or high timeout value (#13942)
| From: | Kévin Dunglas via GitHub | Date: | Tue, 16 Apr 2024 12:13:42 +0000 |
| Subject: | [php-src] PHP-8.2: fix: zend-max-execution-timers with negative or high timeout value (#13942) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-128133@lists.php.net to get a copy of this message | ||
Author: Kévin Dunglas (dunglas)
Committer: GitHub (web-flow)
Pusher: arnaud-lb
Date: 2024-04-16T14:13:36+02:00
Commit: https://github.com/php/php-src/commit/f6e8145b475f0b39046dd081372e5335acf5e174
Raw diff: https://github.com/php/php-src/commit/f6e8145b475f0b39046dd081372e5335acf5e174.diff
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
Changed paths:
M Zend/zend_execute_API.c
M Zend/zend_max_execution_timer.c
Diff:
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index fa5e13dba2ea8..0e2ff263c9a85 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 48a4d1bd66415..f9f9740fd8a00 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;