[php-src] master: Merge branch 'PHP-8.5'
| From: | Ilia Alshanetsky | Date: | Sat, 19 Sep 2026 21:23:52 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141290@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-19T17:22:59-04:00
Commit: https://github.com/php/php-src/commit/1e8f7ee74b39806af6022e30cf33dfd7ec03b6f8
Raw diff: https://github.com/php/php-src/commit/1e8f7ee74b39806af6022e30cf33dfd7ec03b6f8.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
Fix heap over-read in cli_get_prompt() for empty cli.prompt
Changed paths:
M NEWS
M ext/readline/readline_cli.c
Diff:
diff --git a/NEWS b/NEWS
index fdb9a6128725..16b92c67d3d5 100644
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,10 @@ PHP NEWS
. Reverted the validity check on the flags argument of posix_access().
(David Carlier)
+- Readline:
+ . Fixed a heap over-read in the interactive shell prompt when cli.prompt is
+ set to an empty string. (Ilia Alshanetsky)
+
- SPL:
. Fixed bug GH-23385 (SplDoublyLinkedList::serialize() use-after-free when
__serialize() removes an element). (David Carlier)
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 7d3ed3c60564..1fe7c9c6b4df 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -128,7 +128,7 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
char *prompt_spec = CLIR_G(prompt) ? CLIR_G(prompt) : DEFAULT_PROMPT;
bool unicode_warned = false;
- do {
+ while (*prompt_spec) {
if (*prompt_spec == '\\') {
switch (prompt_spec[1]) {
case '\\':
@@ -196,9 +196,9 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
smart_str_appendc(&retval, '?');
}
}
- } while (++prompt_spec && *prompt_spec);
- smart_str_0(&retval);
- return retval.s;
+ ++prompt_spec;
+ }
+ return smart_str_extract(&retval);
}
/* }}} */