Skip to content

Commit 377d353

Browse files
committed
add error check to sysconf call
1 parent 7d875fb commit 377d353

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/standard/exec.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#include <unistd.h>
5151
#endif
5252

53+
#if HAVE_LIMITS_H
54+
#include <limits.h>
55+
#endif
56+
5357
#ifdef PHP_WIN32
5458
# include "win32/php_stdint.h"
5559
#else
@@ -67,6 +71,13 @@ PHP_MINIT_FUNCTION(exec)
6771
{
6872
#ifdef _SC_ARG_MAX
6973
cmd_max_len = sysconf(_SC_ARG_MAX);
74+
if (-1 == cmd_max_len) {
75+
#ifdef _POSIX_ARG_MAX
76+
cmd_max_len = _POSIX_ARG_MAX;
77+
#else
78+
cmd_max_len = 4096;
79+
#endif
80+
}
7081
#elif defined(ARG_MAX)
7182
cmd_max_len = ARG_MAX;
7283
#elif defined(PHP_WIN32)

0 commit comments

Comments
 (0)