[php-src] PHP-8.5: Fix posix_setrlimit() rejecting POSIX_RLIMIT_INFINITY on Solaris

From: Date: Sun, 18 Oct 2026 18:10:37 +0000
Subject: [php-src] PHP-8.5: Fix posix_setrlimit() rejecting POSIX_RLIMIT_INFINITY on Solaris
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142418@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-10-18T20:07:22+02:00 Commit: https://github.com/php/php-src/commit/602ba3ac97027080d074d18cb590d6fd105789ff Raw diff: https://github.com/php/php-src/commit/602ba3ac97027080d074d18cb590d6fd105789ff.diff Fix posix_setrlimit() rejecting POSIX_RLIMIT_INFINITY on Solaris GH-19281 made posix_setrlimit() throw a ValueError for limits below -1, on the assumption that -1 (RLIM_INFINITY on Linux) is the only valid negative value. Solaris defines RLIM_INFINITY as (rlim_t)-3, so the function now rejects PHP's own POSIX_RLIMIT_INFINITY constant: ValueError: posix_setrlimit(): Argument #3 ($hard_limit) must be greater or equal to -1 On Solaris, also accept RLIM_INFINITY. Other platforms keep the existing check. This fixes ext/session/tests/session_write_failure_keeps_data.phpt in the nightly SOLARIS job. See https://docs.oracle.com/cd/E88353_01/html/E37841/setrlimit-2.html and https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/resource.h Changed paths: M NEWS M ext/posix/posix.c Diff: diff --git a/NEWS b/NEWS index f3377bef23ab..ce0aa590776a 100644 --- a/NEWS +++ b/NEWS @@ -75,6 +75,10 @@ PHP NEWS - Phpdbg: . Fix wrong command names. (ndossche, Weilin Du) +- POSIX: + . Fixed posix_setrlimit() rejecting POSIX_RLIMIT_INFINITY on Solaris. + (Jorg Sowa) + - Readline: . Fixed a crash in readline_info() when completion_append_character contains a non-ASCII byte. (Weilin Du) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index e4c2b91678e9..b8d2e5a21a27 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -1217,7 +1217,14 @@ PHP_FUNCTION(posix_getrlimit) #endif /* HAVE_GETRLIMIT */ #ifdef HAVE_SETRLIMIT -/* {{{ Set system resource consumption limits (POSIX.1-2001) */ +/* Solaris defines RLIM_INFINITY as (rlim_t)-3, so POSIX_RLIMIT_INFINITY is below -1 */ +#ifdef __sun +# define POSIX_RLIM_VALID(v) ((v) >= -1 || (v) == (zend_long) RLIM_INFINITY) +#else +# define POSIX_RLIM_VALID(v) ((v) >= -1) +#endif + +/* Set system resource consumption limits (POSIX.1-2001) */ PHP_FUNCTION(posix_setrlimit) { struct rlimit rl; @@ -1229,12 +1236,12 @@ PHP_FUNCTION(posix_setrlimit) Z_PARAM_LONG(max) ZEND_PARSE_PARAMETERS_END(); - if (cur < -1) { + if (!POSIX_RLIM_VALID(cur)) { zend_argument_value_error(2, "must be greater or equal to -1"); RETURN_THROWS(); } - if (max < -1) { + if (!POSIX_RLIM_VALID(max)) { zend_argument_value_error(3, "must be greater or equal to -1"); RETURN_THROWS(); } @@ -1254,7 +1261,6 @@ PHP_FUNCTION(posix_setrlimit) RETURN_TRUE; } -/* }}} */ #endif /* HAVE_SETRLIMIT */

« previous php.cvs (#142418) next »