Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -1254,7 +1261,6 @@ PHP_FUNCTION(posix_setrlimit)

RETURN_TRUE;
}
/* }}} */

#endif /* HAVE_SETRLIMIT */

Expand Down
Loading