Skip to contentSkip to conversation

qemu-option: reject empty number value

PATCH In review Marc-André Lureau 3 participants 3 messages Feb 6, 2017 – Feb 20, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-option: reject empty number value

When no number is provided, return an invalid number error. (note: this may break some users relying on default 0 value)

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1417864

---
 util/qemu-option.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/qemu-option.c +1 -1
index 3467dc2397..89afa4b2c3 100644
@@ -150,7 +150,7 @@ static void parse_option_number(const char *name, const char *value,
 
     if (value != NULL) {
         number = strtoull(value, &postfix, 0);
-        if (*postfix != '\0') {
+        if (*postfix != '\0' || postfix == value) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
             return;
         }
Signature · 1 line
2.11.0.295.gd7dffce1c.dirty
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Marc-André Lureau

When no number is provided, return an invalid number error. (note: this may break some users relying on default 0 value)

Anyone that writes 'size=' instead of 'size=0' deserves the breakage.

Quoted 8 lines

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1417864

---
 util/qemu-option.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to Marc-André Lureau
Quoted 16 lines · Marc-André Lureau

When no number is provided, return an invalid number error. (note: this may break some users relying on default 0 value)

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1417864

---
 util/qemu-option.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/qemu-option.c +0 -0
index 3467dc2397..89afa4b2c3 100644

util/qemu-option.c static void parse_option_number(const char *name, const char *value, · line 156

Quoted 8 lines
util/qemu-option.c +1 -1
@@ -150,7 +150,7 @@ static void parse_option_number(const char *name, const char *value,
 
     if (value != NULL) {
         number = strtoull(value, &postfix, 0);
-        if (*postfix != '\0') {
+        if (*postfix != '\0' || postfix == value) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
             return;
         }

My "[PATCH 09/24] QemuOpts: Fix to reject numbers that overflow uint64_t" is a more comprehensive fix, even though I missed this case both in the tests and the commit message. I'll take care of that in v2.

Thanks!