mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Fix phpdbg segmentation fault in case of malformed input
If you were to enter "w $>" the function would crash with a segmentation fault because last_index is still NULL at that point. Fix it by checking for NULL and erroring out if it is. Closes GH-10353 Signed-off-by: George Peter Banyard <girgias@php.net>
This commit is contained in:
parent
dfe9c2af19
commit
398a10a58a
1
NEWS
1
NEWS
@ -46,6 +46,7 @@ PHP NEWS
|
||||
. Fix undefined behaviour in phpdbg_load_module_or_extension(). (nielsdos)
|
||||
. Fix NULL pointer dereference in phpdbg_create_conditional_breal(). (nielsdos)
|
||||
. Fix GH-9710: phpdbg memory leaks by option "-h" (nielsdos)
|
||||
. Fix phpdbg segmentation fault in case of malformed input (nielsdos)
|
||||
|
||||
- Posix:
|
||||
. Fix memory leak in posix_ttyname() (girgias)
|
||||
|
@ -466,6 +466,9 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
|
||||
case ']':
|
||||
break;
|
||||
case '>':
|
||||
if (!last_index) {
|
||||
goto error;
|
||||
}
|
||||
if (last_index[index_len - 1] == '-') {
|
||||
new_index = 1;
|
||||
index_len--;
|
||||
|
25
sapi/phpdbg/tests/watch_007.phpt
Normal file
25
sapi/phpdbg/tests/watch_007.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Test malformed watchpoint name
|
||||
--INI--
|
||||
opcache.optimization_level=0
|
||||
--PHPDBG--
|
||||
b test
|
||||
r
|
||||
w $>
|
||||
q
|
||||
--EXPECTF--
|
||||
[Successful compilation of %s]
|
||||
prompt> [Breakpoint #0 added at test]
|
||||
prompt> [Breakpoint #0 in test() at %s:%d, hits: 1]
|
||||
>00004: }
|
||||
00005: test();
|
||||
00006: $a = 2;
|
||||
prompt> [Malformed input]
|
||||
prompt>
|
||||
--FILE--
|
||||
<?php
|
||||
$a = 1;
|
||||
function test() {
|
||||
}
|
||||
test();
|
||||
$a = 2;
|
Loading…
Reference in New Issue
Block a user