Skip to content

Commit f6e8145

Browse files
authored
fix: zend-max-execution-timers with negative or high timeout value (php#13942)
Align the behavior of zend-max-execution-timers with other timeout impls: Negative or very high timeout values are equivalent to no timeout
1 parent 32efc76 commit f6e8145

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Zend/zend_execute_API.c

+5
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,11 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
15181518
struct itimerval t_r; /* timeout requested */
15191519
int signo;
15201520

1521+
// Prevent EINVAL error
1522+
if (seconds < 0 || seconds > 999999999) {
1523+
seconds = 0;
1524+
}
1525+
15211526
if(seconds) {
15221527
t_r.it_value.tv_sec = seconds;
15231528
t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;

Zend/zend_max_execution_timer.c

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ void zend_max_execution_timer_settime(zend_long seconds) /* {{{ }*/
7171

7272
timer_t timer = EG(max_execution_timer_timer);
7373

74+
// Prevent EINVAL error
75+
if (seconds < 0 || seconds > 999999999) {
76+
seconds = 0;
77+
}
78+
7479
struct itimerspec its;
7580
its.it_value.tv_sec = seconds;
7681
its.it_value.tv_nsec = its.it_interval.tv_sec = its.it_interval.tv_nsec = 0;

0 commit comments

Comments
 (0)