Skip to content

Commit

Permalink
Merge branch 'PHP-7.3' into PHP-7.4
Browse files Browse the repository at this point in the history
* PHP-7.3:
  Fixed bug #79570
  • Loading branch information
nikic committed Jun 19, 2020
2 parents 2f56b00 + 6aff9a5 commit 525d8a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ PHP NEWS

- Standard:
. Fixed bug #74267 (segfault with streams and invalid data). (cmb)
. Fixed bug #79579 (ZTS build of PHP 7.3.17 doesn't handle ERANGE for
posix_getgrgid and others). (Böszörményi Zoltán)

11 Jun 2020, PHP 7.4.7

Expand Down
18 changes: 18 additions & 0 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,14 @@ PHP_FUNCTION(posix_getgrgid)

grbuf = emalloc(grbuflen);

try_again:
ret = getgrgid_r(gid, &_g, grbuf, grbuflen, &retgrptr);
if (ret || retgrptr == NULL) {
if (errno == ERANGE) {
grbuflen *= 2;
grbuf = erealloc(grbuf, grbuflen);
goto try_again;
}
POSIX_G(last_error) = ret;
efree(grbuf);
RETURN_FALSE;
Expand Down Expand Up @@ -1217,7 +1223,13 @@ PHP_FUNCTION(posix_getpwnam)
buf = emalloc(buflen);
pw = &pwbuf;

try_again:
if (getpwnam_r(name, pw, buf, buflen, &pw) || pw == NULL) {
if (errno == ERANGE) {
buflen *= 2;
buf = erealloc(buf, buflen);
goto try_again;
}
efree(buf);
POSIX_G(last_error) = errno;
RETURN_FALSE;
Expand Down Expand Up @@ -1266,8 +1278,14 @@ PHP_FUNCTION(posix_getpwuid)
}
pwbuf = emalloc(pwbuflen);

try_again:
ret = getpwuid_r(uid, &_pw, pwbuf, pwbuflen, &retpwptr);
if (ret || retpwptr == NULL) {
if (errno == ERANGE) {
pwbuflen *= 2;
pwbuf = erealloc(pwbuf, pwbuflen);
goto try_again;
}
POSIX_G(last_error) = ret;
efree(pwbuf);
RETURN_FALSE;
Expand Down

0 comments on commit 525d8a8

Please sign in to comment.