Skip to content

Commit 789a37f

Browse files
yiyuanerdevnexen
authored andcommitted
Prevent potential buffer overflow for large value of php_cli_server_workers_max
Fixes php#8989. Closes php#9000.
1 parent 77e954a commit 789a37f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Diff for: NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2022, PHP 8.0.22
44

5+
- CLI:
6+
. Fixed potential overflow for the builtin server via the PHP_CLI_SERVER_WORKERS
7+
environment variable. (yiyuaner)
8+
59
- Core:
610
. Fixed bug GH-8923 (error_log on Windows can hold the file write lock). (cmb)
711

Diff for: sapi/cli/php_cli_server.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */
22992299
!WIFSIGNALED(php_cli_server_worker_status));
23002300
}
23012301

2302-
free(php_cli_server_workers);
2302+
pefree(php_cli_server_workers, 1);
23032303
}
23042304
#endif
23052305
} /* }}} */
@@ -2385,12 +2385,8 @@ static void php_cli_server_startup_workers() {
23852385
if (php_cli_server_workers_max > 1) {
23862386
zend_long php_cli_server_worker;
23872387

2388-
php_cli_server_workers = calloc(
2389-
php_cli_server_workers_max, sizeof(pid_t));
2390-
if (!php_cli_server_workers) {
2391-
php_cli_server_workers_max = 1;
2392-
return;
2393-
}
2388+
php_cli_server_workers = pecalloc(
2389+
php_cli_server_workers_max, sizeof(pid_t), 1);
23942390

23952391
php_cli_server_master = getpid();
23962392

0 commit comments

Comments
 (0)