[php-src] master: Merge branch 'PHP-8.3'
| From: | Arnaud Le Blanc | Date: | Tue, 16 Apr 2024 12:22:53 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.3' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-128137@lists.php.net to get a copy of this message | ||
Author: Arnaud Le Blanc (arnaud-lb)
Date: 2024-04-16T14:20:23+02:00
Commit: https://github.com/php/php-src/commit/af5db45dc910f40fbd526b4035788a9c735ffd01
Raw diff: https://github.com/php/php-src/commit/af5db45dc910f40fbd526b4035788a9c735ffd01.diff
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 (#13942)
Use return value of getpwuid_r(), not errno (#13969)
Changed paths:
M Zend/zend_execute_API.c
M Zend/zend_max_execution_timer.c
M ext/posix/posix.c
Diff:
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 5e0d0567cd7ea..bb341ab5c03d2 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1554,6 +1554,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 16c2b7e2b8d23..6f09d2fa22707 100644
--- a/Zend/zend_max_execution_timer.c
+++ b/Zend/zend_max_execution_timer.c
@@ -85,6 +85,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;
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index 6d72ae14a8866..9b06d8554f2a4 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -1009,7 +1009,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;