Skip to content

Commit 56c320c

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

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 7 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+
pefree(php_cli_server_workers, 1);
23392339
}
23402340
#endif
23412341
} /* }}} */
@@ -2421,12 +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));
2426-
if (!php_cli_server_workers) {
2427-
php_cli_server_workers_max = 1;
2428-
return;
2429-
}
2424+
php_cli_server_workers = pecalloc(
2425+
php_cli_server_workers_max, sizeof(pid_t), 1);
24302426

24312427
php_cli_server_master = getpid();
24322428

0 commit comments

Comments
 (0)