Skip to content

Commit

Permalink
Prevent potential buffer overflow for large value of php_cli_server_w…
Browse files Browse the repository at this point in the history
…orkers_max

Fixes #8989.
Closes #9000.
  • Loading branch information
yiyuaner authored and devnexen committed Jul 14, 2022
1 parent 77e954a commit 789a37f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -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)

Expand Down
10 changes: 3 additions & 7 deletions sapi/cli/php_cli_server.c
Expand Up @@ -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
} /* }}} */
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 789a37f

Please sign in to comment.