Skip to content

Commit af5db45

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: [ci skip] NEWS [ci skip] NEWS fix: zend-max-execution-timers with negative or high timeout value (php#13942) Use return value of getpwuid_r(), not errno (php#13969)
2 parents 326dc17 + 812d19d commit af5db45

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Zend/zend_execute_API.c

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

1557+
// Prevent EINVAL error
1558+
if (seconds < 0 || seconds > 999999999) {
1559+
seconds = 0;
1560+
}
1561+
15571562
if(seconds) {
15581563
t_r.it_value.tv_sec = seconds;
15591564
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
@@ -85,6 +85,11 @@ void zend_max_execution_timer_settime(zend_long seconds) /* {{{ }*/
8585

8686
timer_t timer = EG(max_execution_timer_timer);
8787

88+
// Prevent EINVAL error
89+
if (seconds < 0 || seconds > 999999999) {
90+
seconds = 0;
91+
}
92+
8893
struct itimerspec its;
8994
its.it_value.tv_sec = seconds;
9095
its.it_value.tv_nsec = its.it_interval.tv_sec = its.it_interval.tv_nsec = 0;

ext/posix/posix.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ PHP_FUNCTION(posix_getpwuid)
10091009
try_again:
10101010
err = getpwuid_r(uid, &_pw, pwbuf, pwbuflen, &retpwptr);
10111011
if (err || retpwptr == NULL) {
1012-
if (errno == ERANGE) {
1012+
if (err == ERANGE) {
10131013
pwbuflen *= 2;
10141014
pwbuf = erealloc(pwbuf, pwbuflen);
10151015
goto try_again;

0 commit comments

Comments
 (0)