From: Cole Robinson Date: Fri, 24 Jul 2009 15:05:28 +0000 (-0400) Subject: Don't allow NULL paths for BlockStats and InterfaceStats X-Git-Tag: v0.7.0~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13f3d40cbf23159ee28e02436fcad61b8a44d860;p=thirdparty%2Flibvirt.git Don't allow NULL paths for BlockStats and InterfaceStats Do the check in libvirt.c, to save drivers from the burden. This changes behavior slightly in the qemu driver: we no longer explictly error if passed an empty string. An error will still be thrown when the device lookup fails. --- diff --git a/src/libvirt.c b/src/libvirt.c index 1752e9d939..61a9b7c62a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3599,7 +3599,7 @@ virDomainBlockStats (virDomainPtr dom, const char *path, virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); return -1; } - if (!stats || size > sizeof stats2) { + if (!path || !stats || size > sizeof stats2) { virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__); goto error; } @@ -3657,7 +3657,7 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path, virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); return -1; } - if (!stats || size > sizeof stats2) { + if (!path || !stats || size > sizeof stats2) { virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__); goto error; } diff --git a/src/qemu_driver.c b/src/qemu_driver.c index ac0b80fb2f..c594495cfa 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -5704,12 +5704,6 @@ qemudDomainInterfaceStats (virDomainPtr dom, goto cleanup; } - if (!path || path[0] == '\0') { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - "%s", _("NULL or empty path")); - goto cleanup; - } - /* Check the path is one of the domain's network interfaces. */ for (i = 0 ; i < vm->def->nnets ; i++) { if (vm->def->nets[i]->ifname &&