From 65b54baac41e25492dcc3d4e35871bbb9c3755fa Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 22 Feb 2007 23:40:25 +0000 Subject: [PATCH] check for buflen (on FreeBSD _SC_GETGR_R_SIZE_MAX is not implemented) patch by stas at FreeBSD dot org --- ext/posix/posix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 35e9bda16f..97ec512366 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -885,6 +885,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); -- 2.50.1