Skip to content

Commit 76c4a17

Browse files
committed
Fixed bug #62881 (posix_getpwnam("") & posix_getgrnam("") didn't return false on Mac OSX 10.8)
1 parent 60ad16e commit 76c4a17

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ext/posix/posix.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,11 @@ PHP_FUNCTION(posix_getgrnam)
10181018
RETURN_FALSE;
10191019
}
10201020

1021+
/* getgrnam/_r() is buggy on Mac OSX 10.8, do early check for invalid empty name */
1022+
if (name_len == 0) {
1023+
RETURN_FALSE;
1024+
}
1025+
10211026
#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
10221027
buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
10231028
if (buflen < 1) {
@@ -1120,7 +1125,7 @@ int php_posix_passwd_to_array(struct passwd *pw, zval *return_value) /* {{{ */
11201125
}
11211126
/* }}} */
11221127

1123-
/* {{{ proto array posix_getpwnam(string groupname)
1128+
/* {{{ proto array posix_getpwnam(string username)
11241129
User database access (POSIX.1, 9.2.2) */
11251130
PHP_FUNCTION(posix_getpwnam)
11261131
{
@@ -1137,6 +1142,11 @@ PHP_FUNCTION(posix_getpwnam)
11371142
RETURN_FALSE;
11381143
}
11391144

1145+
/* getpwnam/_r() is buggy on Mac OSX 10.8, do early check for invalid empty name */
1146+
if (name_len == 0) {
1147+
RETURN_FALSE;
1148+
}
1149+
11401150
#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
11411151
buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
11421152
if (buflen < 1) {

0 commit comments

Comments
 (0)