diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2018-09-01 14:29:26 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2018-09-01 14:30:08 +0200 |
commit | 0a51e75e286b03806cbdae99d53a598dac1e8734 (patch) | |
tree | 2663d5ae9139526be90d797b36361fe67bcb1b8d | |
parent | bcfe5f58451d574480453b98b02e2b4bd46df687 (diff) | |
parent | 7bcda659f810d55041fbe3b76823ba4c10c03928 (diff) | |
download | php-git-0a51e75e286b03806cbdae99d53a598dac1e8734.tar.gz |
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
Fix #75696: posix_getgrnam fails to print details of group
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/posix/posix.c | 6 | ||||
-rw-r--r-- | ext/posix/tests/bug75696.phpt | 17 |
3 files changed, 26 insertions, 0 deletions
@@ -9,6 +9,9 @@ PHP NEWS . Fixed bug #76829 (Incorrect validation of domain on idn_to_utf8() function). (Anatol) +- POSIX: + Fixed bug #75696 (posix_getgrnam fails to print details of group). (cmb) + - Standard: . Fixed bug #76803 (ftruncate changes file pointer). (Anatol) . Fixed bug #76818 (Memory corruption and segfault). (Remi) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 0d8edde4e2..5a2f352e41 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -1081,9 +1081,15 @@ PHP_FUNCTION(posix_getgrnam) RETURN_FALSE; } buf = emalloc(buflen); +try_again: g = &gbuf; if (getgrnam_r(name, g, buf, buflen, &g) || g == NULL) { + if (errno == ERANGE) { + buflen *= 2; + buf = erealloc(buf, buflen); + goto try_again; + } POSIX_G(last_error) = errno; efree(buf); RETURN_FALSE; diff --git a/ext/posix/tests/bug75696.phpt b/ext/posix/tests/bug75696.phpt new file mode 100644 index 0000000000..e37f8077ce --- /dev/null +++ b/ext/posix/tests/bug75696.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #75696 (posix_getgrnam fails to print details of group) +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip posix extension not available'); +?> +--FILE-- +<?php +$gid = posix_getgid(); +$name = posix_getgrgid($gid)['name']; +$info = posix_getgrnam($name); +var_dump(is_array($info)); +?> +===DONE=== +--EXPECT-- +bool(true) +===DONE=== |