Skip to content

Commit a6d17bf

Browse files
committed
Fix GH-12962: Double free of init_file in phpdbg_prompt.c
See GH-12962 for analysis. Closes GH-12963.
1 parent 40ccc8e commit a6d17bf

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ PHP NEWS
2020
. Added workaround for SELinux mprotect execheap issue.
2121
See https://bugzilla.kernel.org/show_bug.cgi?id=218258. (ilutov)
2222

23+
- PHPDBG:
24+
. Fixed bug GH-12962 (Double free of init_file in phpdbg_prompt.c). (nielsdos)
25+
2326
21 Dec 2023, PHP 8.2.14
2427

2528
- Core:

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void phpdbg_init(char *init_file, size_t init_file_len, bool use_default) /* {{{
364364
}
365365

366366
ZEND_IGNORE_VALUE(asprintf(&init_file, "%s/%s", scan_dir, PHPDBG_INIT_FILENAME));
367-
phpdbg_try_file_init(init_file, strlen(init_file), 1);
367+
phpdbg_try_file_init(init_file, strlen(init_file), 0);
368368
free(init_file);
369369
if (i == -1) {
370370
break;

sapi/phpdbg/tests/gh12962.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
GH-12962 (Double free of init_file in phpdbg_prompt.c)
3+
--SKIPIF--
4+
<?php
5+
if (!getenv('TEST_PHPDBG_EXECUTABLE')) die("SKIP: No TEST_PHPDBG_EXECUTABLE specified");
6+
?>
7+
--FILE--
8+
<?php
9+
putenv('PHP_INI_SCAN_DIR='.__DIR__."/gh12962");
10+
passthru($_ENV['TEST_PHPDBG_EXECUTABLE'] . " -q");
11+
?>
12+
--EXPECT--
13+
Executed .phpdbginit

sapi/phpdbg/tests/gh12962/.phpdbginit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ev "Executed .phpdbginit"
2+
q

0 commit comments

Comments
 (0)