php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch php-7.3-fix-posix-fns-with-zts.patch for POSIX related Bug #79570

Patch version 2020-05-06 06:53 UTC

Return to Bug #79570 | Download this patch
Patch Revisions:

Developer: zboszor@pr.hu

--- php-7.3.17.old/ext/posix/posix.c	2020-04-14 10:29:29.000000000 +0200
+++ php-7.3.17/ext/posix/posix.c	2020-05-05 13:53:09.471329099 +0200
@@ -1140,8 +1140,14 @@
 
 	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 @@
 	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 @@
 	}
 	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;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC