Skip to content

Fix heap over-read in cli_get_prompt() for empty cli.prompt - #252

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/readline-cli-prompt-empty
Closed

Fix heap over-read in cli_get_prompt() for empty cli.prompt#252
iliaal wants to merge 1 commit into
PHP-8.4from
fix/readline-cli-prompt-empty

Conversation

@iliaal

@iliaal iliaal commented Aug 21, 2026

Copy link
Copy Markdown
Owner

cli_get_prompt() parsed cli.prompt with a do-while, so the empty string executed the body on the terminator and scanned heap past it. Use a while loop and return the interned empty string when nothing was appended.

@iliaal
iliaal force-pushed the fix/readline-cli-prompt-empty branch 3 times, most recently from e874971 to 979385f Compare August 21, 2026 20:42
The prompt parser ran as a do-while, so an empty cli.prompt executed
the body on the terminator and scanned past it. Use a while loop and
return the interned empty string when nothing was appended. No
regression test: extra unicode warnings from the over-read depend on
heap contents, so a .phpt cannot pin the bug red-before.
@iliaal
iliaal force-pushed the fix/readline-cli-prompt-empty branch from 979385f to 78a6f6a Compare August 22, 2026 15:04
@iliaal

iliaal commented Aug 22, 2026

Copy link
Copy Markdown
Owner Author

Upstream: php#23415

@iliaal iliaal closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant