Skip to content

Commit 0a51e75

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #75696: posix_getgrnam fails to print details of group
2 parents bcfe5f5 + 7bcda65 commit 0a51e75

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
. Fixed bug #76829 (Incorrect validation of domain on idn_to_utf8()
1010
function). (Anatol)
1111

12+
- POSIX:
13+
Fixed bug #75696 (posix_getgrnam fails to print details of group). (cmb)
14+
1215
- Standard:
1316
. Fixed bug #76803 (ftruncate changes file pointer). (Anatol)
1417
. Fixed bug #76818 (Memory corruption and segfault). (Remi)

ext/posix/posix.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,15 @@ PHP_FUNCTION(posix_getgrnam)
10811081
RETURN_FALSE;
10821082
}
10831083
buf = emalloc(buflen);
1084+
try_again:
10841085
g = &gbuf;
10851086

10861087
if (getgrnam_r(name, g, buf, buflen, &g) || g == NULL) {
1088+
if (errno == ERANGE) {
1089+
buflen *= 2;
1090+
buf = erealloc(buf, buflen);
1091+
goto try_again;
1092+
}
10871093
POSIX_G(last_error) = errno;
10881094
efree(buf);
10891095
RETURN_FALSE;

ext/posix/tests/bug75696.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #75696 (posix_getgrnam fails to print details of group)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('posix')) die('skip posix extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$gid = posix_getgid();
10+
$name = posix_getgrgid($gid)['name'];
11+
$info = posix_getgrnam($name);
12+
var_dump(is_array($info));
13+
?>
14+
===DONE===
15+
--EXPECT--
16+
bool(true)
17+
===DONE===

0 commit comments

Comments
 (0)