diff --git a/NEWS b/NEWS index 4b737751b074..94ec1e8ecfa0 100644 --- a/NEWS +++ b/NEWS @@ -72,6 +72,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 */