Skip to contentSkip to conversation

monitor.c: Fix infinite loop in monitor's auto-complete functionality

PATCH In review Dimitris Karagkasidis 2 participants 2 messages Feb 13, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 monitor.c: Fix infinite loop in monitor's auto-complete functionality

The QEMU monitor enters an infinite loop when trying to auto-complete commands that accept only optional parameters. The commands currently affected by this issue are 'info registers' and 'info mtree'.

---
 monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor.c +1 -1
index f4992505b1..d8b7270d9b 100644
@@ -3741,7 +3741,7 @@ static void monitor_find_completion_by_table(Monitor *mon,
             }
         }
         str = args[nb_args - 1];
-        while (*ptype == '-' && ptype[1] != '\0') {
+        while (*ptype == '-' && ptype[2] != '\0') {
             ptype = next_arg_type(ptype);
         }
         switch(*ptype) {
Signature · 1 line
2.14.1
#1 lore raw
Quoted 5 lines · * Dimitris Karagkasidis ([email protected]) wrote:

The QEMU monitor enters an infinite loop when trying to auto-complete commands that accept only optional parameters. The commands currently affected by this issue are 'info registers' and 'info mtree'.

Hi Dimitris,
Thanks for that, I guess this has been broken since 48fe86f6.

Your patch does fix it, but I prefer a slightly different fix which I'll post in a minute, which is a bit more robust to other things going wrong.

Dave

Quoted 19 lines
---
 monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor.c +1 -1
index f4992505b1..d8b7270d9b 100644
@@ -3741,7 +3741,7 @@ static void monitor_find_completion_by_table(Monitor *mon,
             }
         }
         str = args[nb_args - 1];
-        while (*ptype == '-' && ptype[1] != '\0') {
+        while (*ptype == '-' && ptype[2] != '\0') {
             ptype = next_arg_type(ptype);
         }
         switch(*ptype) {
Signature · 1 line
2.14.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK