mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fixed bug #79570
Use the same logic for getgrgid_r, getpwnam_r and getpwuid_r as for getgrnam_r in #75696 Closes GH-5740.
This commit is contained in:
parent
32f377b0b9
commit
6aff9a50ca
2
NEWS
2
NEWS
@ -32,6 +32,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.3.19
|
||||
|
||||
|
@ -1140,8 +1140,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;
|
||||
@ -1209,7 +1215,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;
|
||||
@ -1258,8 +1270,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;
|
||||
|
Loading…
Reference in New Issue
Block a user