Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ PHP NEWS
or never terminates). (Ilia Alshanetsky)
. Fixed memory leak in JIT ASSIGN_DIM when the assignment fails. (Jorg Sowa)

- Readline:
. Fixed incorrect handling of non-ASCII pending_input bytes in readline_info(),
which could cause readline() to return false prematurely. (Weilin Du)

- Streams:
. Fixed bug GH-22063 (Stream filter chain UAF on self-removal during
callback). (Ilia Alshanetsky)
Expand Down
2 changes: 1 addition & 1 deletion ext/readline/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ PHP_FUNCTION(readline_info)
if (!try_convert_to_string(value)) {
RETURN_THROWS();
}
rl_pending_input = Z_STRVAL_P(value)[0];
rl_pending_input = (unsigned char)Z_STRVAL_P(value)[0];
}
RETVAL_LONG(oldval);
} else if (zend_string_equals_literal_ci(what, "prompt")) {
Expand Down
28 changes: 28 additions & 0 deletions ext/readline/tests/readline_info_pending_input.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
readline_info(): pending_input supports non-ASCII bytes
--EXTENSIONS--
readline
--SKIPIF--
<?php
if (READLINE_LIB !== 'readline') die('skip readline only');
?>
--FILE--
<?php
readline_info('pending_input', '');
foreach (["\x7f", "\x80", "\xfe", "\xfftail", ''] as $value) {
$old = readline_info('pending_input', $value);
$current = readline_info('pending_input');
$info = readline_info();
printf("old=%d current=%d info=%d\n",
$old,
$current,
$info['pending_input']
);
}
?>
--EXPECT--
old=0 current=127 info=127
old=127 current=128 info=128
old=128 current=254 info=254
old=254 current=255 info=255
old=255 current=0 info=0
Loading