mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix GH-10611: fpm_env_init_main leaks environ
This commit is contained in:
commit
6a44705f4e
3
NEWS
3
NEWS
@ -16,6 +16,9 @@ PHP NEWS
|
||||
. Fixed bug GH-10747 (Private and protected properties in serialized Date*
|
||||
objects throw). (Derick)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug GH-10611 (fpm_env_init_main leaks environ). (nielsdos)
|
||||
|
||||
- FTP:
|
||||
. Propagate success status of ftp_close(). (nielsdos)
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "fpm_env.h"
|
||||
#include "fpm.h"
|
||||
#include "fpm_cleanup.h"
|
||||
|
||||
#ifndef HAVE_SETPROCTITLE
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
@ -194,6 +195,26 @@ static int fpm_env_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
#ifndef HAVE_SETPROCTITLE
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
/* Frees our copied environment variables. */
|
||||
static void fpm_env_cleanup(int which, void *arg) /* {{{ */
|
||||
{
|
||||
char** allocated_environ = environ;
|
||||
if (allocated_environ) {
|
||||
environ = NULL;
|
||||
unsigned int i = 0;
|
||||
while (allocated_environ[i]) {
|
||||
free(allocated_environ[i]);
|
||||
i++;
|
||||
}
|
||||
free(allocated_environ);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int fpm_env_init_main(void)
|
||||
{
|
||||
struct fpm_worker_pool_s *wp;
|
||||
@ -254,6 +275,10 @@ int fpm_env_init_main(void)
|
||||
env_nb++;
|
||||
}
|
||||
|
||||
if (0 > fpm_cleanup_add(FPM_CLEANUP_PARENT_EXIT_MAIN, fpm_env_cleanup, 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((new_environ = malloc((1U + env_nb) * sizeof (char *))) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user