summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/posix/posix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index 0c37784264..35910e0f28 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -887,6 +887,10 @@ PHP_FUNCTION(posix_getgrgid)
#if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX)
grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
+ if (grbuflen < 1) {
+ RETURN_FALSE;
+ }
+
grbuf = emalloc(grbuflen);
ret = getgrgid_r(gid, &_g, grbuf, grbuflen, &retgrptr);