Skip to content

Commit 2822fb3

Browse files
committed
Prevent potential buffer overflow for large value of php_cli_server_workers_max
1 parent 492f9c6 commit 2822fb3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */
23352335
!WIFSIGNALED(php_cli_server_worker_status));
23362336
}
23372337

2338-
free(php_cli_server_workers);
2338+
efree(php_cli_server_workers);
23392339
}
23402340
#endif
23412341
} /* }}} */
@@ -2421,8 +2421,8 @@ static void php_cli_server_startup_workers(void) {
24212421
if (php_cli_server_workers_max > 1) {
24222422
zend_long php_cli_server_worker;
24232423

2424-
php_cli_server_workers = calloc(
2425-
php_cli_server_workers_max, sizeof(pid_t));
2424+
php_cli_server_workers = safe_emalloc(
2425+
php_cli_server_workers_max, sizeof(pid_t), 0);
24262426
if (!php_cli_server_workers) {
24272427
php_cli_server_workers_max = 1;
24282428
return;

0 commit comments

Comments
 (0)