Skip to content

Commit 7bcda65

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix #75696: posix_getgrnam fails to print details of group
2 parents 1ccc4ff + 2677d43 commit 7bcda65

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2018, PHP 7.2.11
44

5+
- POSIX:
6+
Fixed bug #75696 (posix_getgrnam fails to print details of group). (cmb)
57

68
13 Sep 2018, PHP 7.2.10
79

ext/posix/posix.c

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

10871088
if (getgrnam_r(name, g, buf, buflen, &g) || g == NULL) {
1089+
if (errno == ERANGE) {
1090+
buflen *= 2;
1091+
buf = erealloc(buf, buflen);
1092+
goto try_again;
1093+
}
10881094
POSIX_G(last_error) = errno;
10891095
efree(buf);
10901096
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)