diff options
Diffstat (limited to 'user/php7/no-max-ent-size.patch')
-rw-r--r-- | user/php7/no-max-ent-size.patch | 108 |
1 files changed, 17 insertions, 91 deletions
diff --git a/user/php7/no-max-ent-size.patch b/user/php7/no-max-ent-size.patch index 7f28ba3f1..d6552cf1c 100644 --- a/user/php7/no-max-ent-size.patch +++ b/user/php7/no-max-ent-size.patch @@ -1,6 +1,6 @@ ---- php-7.4.4/ext/posix/posix.c 2020-03-17 10:40:22.000000000 +0000 -+++ php-7.4.4/ext/posix/posix.c 2020-03-27 03:19:13.133440186 +0000 -@@ -1084,8 +1084,11 @@ PHP_FUNCTION(posix_getgrnam) +--- php-7.4.29/ext/posix/posix.c 2022-04-12 10:55:39.000000000 +0000 ++++ php-7.4.29/ext/posix/posix.c 2022-05-27 16:10:31.374379930 +0000 +@@ -1094,8 +1094,11 @@ PHP_FUNCTION(posix_getgrnam) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); #if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX) @@ -13,17 +13,7 @@ RETURN_FALSE; } buf = emalloc(buflen); -@@ -1127,9 +1130,7 @@ PHP_FUNCTION(posix_getgrgid) - { - zend_long gid; - #if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX) -- int ret; - struct group _g; -- struct group *retgrptr = NULL; - long grbuflen; - char *grbuf; - #endif -@@ -1141,20 +1142,27 @@ PHP_FUNCTION(posix_getgrgid) +@@ -1151,8 +1154,11 @@ PHP_FUNCTION(posix_getgrgid) #if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX) @@ -35,29 +25,8 @@ + } else if (grbuflen < 1) { RETURN_FALSE; } -- - grbuf = emalloc(grbuflen); -+try_again: -+ g = &_g; -- ret = getgrgid_r(gid, &_g, grbuf, grbuflen, &retgrptr); -- if (ret || retgrptr == NULL) { -- POSIX_G(last_error) = ret; -+ if (getgrgid_r(gid, g, grbuf, grbuflen, &g) || g == NULL) { -+ if (errno == ERANGE) { -+ grbuflen *= 2; -+ grbuf = erealloc(grbuf, grbuflen); -+ goto try_again; -+ } -+ POSIX_G(last_error) = errno; - efree(grbuf); - RETURN_FALSE; - } -- g = &_g; - #else - if (NULL == (g = getgrgid(gid))) { - POSIX_G(last_error) = errno; -@@ -1210,14 +1218,23 @@ PHP_FUNCTION(posix_getpwnam) +@@ -1226,8 +1232,11 @@ PHP_FUNCTION(posix_getpwnam) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R) @@ -70,30 +39,7 @@ RETURN_FALSE; } buf = emalloc(buflen); -+try_again: - pw = &pwbuf; - - 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; -@@ -1248,10 +1265,8 @@ PHP_FUNCTION(posix_getpwuid) - zend_long uid; - #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R) - struct passwd _pw; -- struct passwd *retpwptr = NULL; - long pwbuflen; - char *pwbuf; -- int ret; - #endif - struct passwd *pw; - -@@ -1260,19 +1275,27 @@ PHP_FUNCTION(posix_getpwuid) +@@ -1282,8 +1291,11 @@ PHP_FUNCTION(posix_getpwuid) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R) @@ -106,29 +52,9 @@ RETURN_FALSE; } pwbuf = emalloc(pwbuflen); -+try_again: -+ pw = &_pw; - -- ret = getpwuid_r(uid, &_pw, pwbuf, pwbuflen, &retpwptr); -- if (ret || retpwptr == NULL) { -- POSIX_G(last_error) = ret; -+ if (getpwuid_r(uid, pw, pwbuf, pwbuflen, &pw) || pw == NULL) { -+ if (errno == ERANGE) { -+ pwbuflen *= 2; -+ pwbuf = erealloc(pwbuf, pwbuflen); -+ goto try_again; -+ } -+ POSIX_G(last_error) = errno; - efree(pwbuf); - RETURN_FALSE; - } -- pw = &_pw; - #else - if (NULL == (pw = getpwuid(uid))) { - POSIX_G(last_error) = errno; ---- php-7.4.4/ext/standard/filestat.c 2020-03-17 10:40:30.000000000 +0000 -+++ php-7.4.4/ext/standard/filestat.c 2020-03-27 04:00:18.333479165 +0000 -@@ -302,15 +302,25 @@ PHPAPI int php_get_gid_by_name(const cha +--- php-7.4.29/ext/standard/filestat.c 2022-04-12 10:55:45.000000000 +0000 ++++ php-7.4.29/ext/standard/filestat.c 2022-05-27 16:12:23.176939839 +0000 +@@ -310,15 +310,25 @@ PHPAPI int php_get_gid_by_name(const cha #if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX) struct group gr; struct group *retgrptr; @@ -156,7 +82,7 @@ efree(grbuf); return FAILURE; } -@@ -438,15 +448,25 @@ PHPAPI uid_t php_get_uid_by_name(const c +@@ -446,15 +456,25 @@ PHPAPI uid_t php_get_uid_by_name(const c #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R) struct passwd pw; struct passwd *retpwptr = NULL; @@ -184,9 +110,9 @@ efree(pwbuf); return FAILURE; } ---- php-7.4.4/main/fopen_wrappers.c 2020-03-17 10:40:21.000000000 +0000 -+++ php-7.4.4/main/fopen_wrappers.c 2020-03-27 04:08:46.553487201 +0000 -@@ -366,10 +366,13 @@ PHPAPI int php_fopen_primary_script(zend +--- php-7.4.29/main/fopen_wrappers.c 2022-04-12 10:55:38.000000000 +0000 ++++ php-7.4.29/main/fopen_wrappers.c 2022-05-27 16:13:13.063261295 +0000 +@@ -375,10 +375,13 @@ PHPAPI int php_fopen_primary_script(zend struct passwd *pw; #if defined(ZTS) && defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX) struct passwd pwstruc; @@ -201,7 +127,7 @@ return FAILURE; } -@@ -382,7 +385,14 @@ PHPAPI int php_fopen_primary_script(zend +@@ -391,7 +394,14 @@ PHPAPI int php_fopen_primary_script(zend memcpy(user, path_info + 2, length); user[length] = '\0'; #if defined(ZTS) && defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX) @@ -217,9 +143,9 @@ efree(pwbuf); return FAILURE; } ---- php-7.4.4/main/main.c 2020-03-17 10:40:21.000000000 +0000 -+++ php-7.4.4/main/main.c 2020-03-27 03:33:22.663453619 +0000 -@@ -1487,23 +1487,27 @@ PHPAPI char *php_get_current_user(void) +--- php-7.4.29/main/main.c 2022-04-12 10:55:38.000000000 +0000 ++++ php-7.4.29/main/main.c 2022-05-27 16:14:26.862749793 +0000 +@@ -1534,23 +1534,27 @@ PHPAPI char *php_get_current_user(void) struct passwd *pwd; #if defined(ZTS) && defined(HAVE_GETPWUID_R) && defined(_SC_GETPW_R_SIZE_MAX) struct passwd _pw; |