Message ID | 87oacjklvb.fsf@blackfin.pond.sub.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
18.01.2016 17:23, Markus Armbruster wrote: [...] > Applied to my monitor-next with these tweaks: > > diff --git a/hmp.c b/hmp.c > index 8be03df..9c571f5 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1739,7 +1739,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) > keyname_len = separator ? separator - keys : strlen(keys); > > /* Be compatible with old interface, convert user inputted "<" */ > - if (!strncmp(keys, "<", 1) && keyname_len == 1) { > + if (keys[0] == '<' && keyname_len == 1) { > keys = "less"; > keyname_len = 4; > } > @@ -1758,7 +1758,8 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) > if (strstart(keys, "0x", NULL)) { > char *endp; > int value = strtoul(keys, &endp, 0); > - if (*endp != '\0' && *endp != '-') { > + assert(endp <= keys + keyname_len); > + if (endp != keys + keyname_len) { > goto err_out; > } > keylist->value->type = KEY_VALUE_KIND_NUMBER; Marcus, where's your monitor-next branch? Repository at git://repo.or.cz/qemu/armbru.git , monitor-next branch does not contain this change, last commit to hmp.c dated Sep-8. Thanks, /mjt
Ping? 26.01.2016 12:36, Michael Tokarev wrote: > 18.01.2016 17:23, Markus Armbruster wrote: > [...] >> Applied to my monitor-next with these tweaks: >> >> diff --git a/hmp.c b/hmp.c >> index 8be03df..9c571f5 100644 >> --- a/hmp.c >> +++ b/hmp.c >> @@ -1739,7 +1739,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) >> keyname_len = separator ? separator - keys : strlen(keys); >> >> /* Be compatible with old interface, convert user inputted "<" */ >> - if (!strncmp(keys, "<", 1) && keyname_len == 1) { >> + if (keys[0] == '<' && keyname_len == 1) { >> keys = "less"; >> keyname_len = 4; >> } >> @@ -1758,7 +1758,8 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) >> if (strstart(keys, "0x", NULL)) { >> char *endp; >> int value = strtoul(keys, &endp, 0); >> - if (*endp != '\0' && *endp != '-') { >> + assert(endp <= keys + keyname_len); >> + if (endp != keys + keyname_len) { >> goto err_out; >> } >> keylist->value->type = KEY_VALUE_KIND_NUMBER; > > Marcus, where's your monitor-next branch? Repository at > git://repo.or.cz/qemu/armbru.git , monitor-next branch does > not contain this change, last commit to hmp.c dated Sep-8. > > Thanks, > > /mjt >
Michael Tokarev <mjt@tls.msk.ru> writes: > Ping? Sorry for the delay, I've been focusing on the QAPI queue to the exclusion of pretty much everything else. > 26.01.2016 12:36, Michael Tokarev wrote: >> 18.01.2016 17:23, Markus Armbruster wrote: >> [...] >>> Applied to my monitor-next with these tweaks: >>> >>> diff --git a/hmp.c b/hmp.c >>> index 8be03df..9c571f5 100644 >>> --- a/hmp.c >>> +++ b/hmp.c >>> @@ -1739,7 +1739,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) >>> keyname_len = separator ? separator - keys : strlen(keys); >>> >>> /* Be compatible with old interface, convert user inputted "<" */ >>> - if (!strncmp(keys, "<", 1) && keyname_len == 1) { >>> + if (keys[0] == '<' && keyname_len == 1) { >>> keys = "less"; >>> keyname_len = 4; >>> } >>> @@ -1758,7 +1758,8 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) >>> if (strstart(keys, "0x", NULL)) { >>> char *endp; >>> int value = strtoul(keys, &endp, 0); >>> - if (*endp != '\0' && *endp != '-') { >>> + assert(endp <= keys + keyname_len); >>> + if (endp != keys + keyname_len) { >>> goto err_out; >>> } >>> keylist->value->type = KEY_VALUE_KIND_NUMBER; >> >> Marcus, where's your monitor-next branch? Repository at >> git://repo.or.cz/qemu/armbru.git , monitor-next branch does >> not contain this change, last commit to hmp.c dated Sep-8. I forgot to push. Should be there now, but needs a rebase to current master.
diff --git a/hmp.c b/hmp.c index 8be03df..9c571f5 100644 --- a/hmp.c +++ b/hmp.c @@ -1739,7 +1739,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) keyname_len = separator ? separator - keys : strlen(keys); /* Be compatible with old interface, convert user inputted "<" */ - if (!strncmp(keys, "<", 1) && keyname_len == 1) { + if (keys[0] == '<' && keyname_len == 1) { keys = "less"; keyname_len = 4; } @@ -1758,7 +1758,8 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) if (strstart(keys, "0x", NULL)) { char *endp; int value = strtoul(keys, &endp, 0); - if (*endp != '\0' && *endp != '-') { + assert(endp <= keys + keyname_len); + if (endp != keys + keyname_len) { goto err_out; } keylist->value->type = KEY_VALUE_KIND_NUMBER;