From e6fc66461800cd3f5cb08e506bb617ad6e91ecf8 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Tue, 16 Sep 2014 10:06:50 +0200 Subject: [PATCH] network: check negative values in bridge queues We already are checking for negative value, reporting an error, but using wrong function and the check only succeeds when a value that cannot be converted to number successfully is encountered. This patch provides just a minor change in call of the right version of function virStrToLong. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1138539 --- src/conf/domain_conf.c | 2 +- .../qemuxml2argv-vhost_queues-invalid.xml | 32 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vhost_queues-invalid.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9cb3ebd5d6..694c6cbad5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7377,7 +7377,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, } if (queues) { unsigned int q; - if (virStrToLong_ui(queues, NULL, 10, &q) < 0) { + if (virStrToLong_uip(queues, NULL, 10, &q) < 0) { virReportError(VIR_ERR_XML_DETAIL, _("'queues' attribute must be positive number: %s"), queues); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-vhost_queues-invalid.xml b/tests/qemuxml2argvdata/qemuxml2argv-vhost_queues-invalid.xml new file mode 100644 index 0000000000..300695abbd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-vhost_queues-invalid.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + bba65c0e-c049-934f-b6aa-4e2c0582acdf + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + restart + + /usr/bin/qemu + + + +
+ + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5c2825329e..0a0c8ec256 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -954,6 +954,7 @@ mymain(void) DO_TEST_FAILURE("misc-enable-s4", NONE); DO_TEST("misc-no-reboot", NONE); DO_TEST("misc-uuid", QEMU_CAPS_NAME, QEMU_CAPS_UUID); + DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE); DO_TEST("net-vhostuser", QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV); DO_TEST("net-user", NONE); DO_TEST("net-virtio", NONE);