Skip to content

Commit 6bad8fd

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix heap over-read in cli_get_prompt() for empty cli.prompt
2 parents 30920e9 + c2c01ae commit 6bad8fd

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
@@ -45,6 +45,10 @@ PHP NEWS
4545
- PGSQL:
4646
. Fixed pg_lo_write() rejecting data containing null bytes. (Ilia Alshanetsky)
4747

48+
- Readline:
49+
. Fixed a heap over-read in the interactive shell prompt when cli.prompt is
50+
set to an empty string. (Ilia Alshanetsky)
51+
4852
- SQLite:
4953
. Fixed a crash when SQLite3::close() is called from a userland callback.
5054
(Ilia Alshanetsky)

‎ext/readline/readline_cli.c‎

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

133-
do {
133+
while (*prompt_spec) {
134134
if (*prompt_spec == '\\') {
135135
switch (prompt_spec[1]) {
136136
case '\\':
@@ -198,9 +198,9 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
198198
smart_str_appendc(&retval, '?');
199199
}
200200
}
201-
} while (++prompt_spec && *prompt_spec);
202-
smart_str_0(&retval);
203-
return retval.s;
201+
++prompt_spec;
202+
}
203+
return smart_str_extract(&retval);
204204
}
205205
/* }}} */
206206

0 commit comments

Comments
 (0)