Skip to content

Commit c12fd08

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: [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 550e0ce + d47aaac commit c12fd08

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Diff for: Zend/zend_execute_API.c

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

1543+
// Prevent EINVAL error
1544+
if (seconds < 0 || seconds > 999999999) {
1545+
seconds = 0;
1546+
}
1547+
15431548
if(seconds) {
15441549
t_r.it_value.tv_sec = seconds;
15451550
t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;

Diff for: 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;

Diff for: ext/posix/posix.c

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

0 commit comments

Comments
 (0)