Prevent potential buffer overflow for large value of php_cli_server_workers_max

Fixes #8989.
Closes #9000.
This commit is contained in:
guoyiyuan 2022-07-13 20:55:51 +08:00 committed by David Carlier
parent 77e954afaa
commit 789a37f144
2 changed files with 7 additions and 7 deletions

4
NEWS
View file

@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2022, PHP 8.0.22
- CLI:
. Fixed potential overflow for the builtin server via the PHP_CLI_SERVER_WORKERS
environment variable. (yiyuaner)
- Core:
. Fixed bug GH-8923 (error_log on Windows can hold the file write lock). (cmb)

View file

@ -2299,7 +2299,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */
!WIFSIGNALED(php_cli_server_worker_status));
}
free(php_cli_server_workers);
pefree(php_cli_server_workers, 1);
}
#endif
} /* }}} */
@ -2385,12 +2385,8 @@ static void php_cli_server_startup_workers() {
if (php_cli_server_workers_max > 1) {
zend_long php_cli_server_worker;
php_cli_server_workers = calloc(
php_cli_server_workers_max, sizeof(pid_t));
if (!php_cli_server_workers) {
php_cli_server_workers_max = 1;
return;
}
php_cli_server_workers = pecalloc(
php_cli_server_workers_max, sizeof(pid_t), 1);
php_cli_server_master = getpid();