Skip to content

Commit 1e8f7ee

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix heap over-read in cli_get_prompt() for empty cli.prompt
2 parents 9e75056 + 6bad8fd commit 1e8f7ee

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ PHP NEWS
5959
. Reverted the validity check on the flags argument of posix_access().
6060
(David Carlier)
6161

62+
- Readline:
63+
. Fixed a heap over-read in the interactive shell prompt when cli.prompt is
64+
set to an empty string. (Ilia Alshanetsky)
65+
6266
- SPL:
6367
. Fixed bug GH-23385 (SplDoublyLinkedList::serialize() use-after-free when
6468
__serialize() removes an element). (David Carlier)

ext/readline/readline_cli.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
128128
char *prompt_spec = CLIR_G(prompt) ? CLIR_G(prompt) : DEFAULT_PROMPT;
129129
bool unicode_warned = false;
130130

131-
do {
131+
while (*prompt_spec) {
132132
if (*prompt_spec == '\\') {
133133
switch (prompt_spec[1]) {
134134
case '\\':
@@ -196,9 +196,9 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
196196
smart_str_appendc(&retval, '?');
197197
}
198198
}
199-
} while (++prompt_spec && *prompt_spec);
200-
smart_str_0(&retval);
201-
return retval.s;
199+
++prompt_spec;
200+
}
201+
return smart_str_extract(&retval);
202202
}
203203
/* }}} */
204204

0 commit comments

Comments
 (0)