mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
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.
This commit is contained in:
parent
3c2051f86a
commit
13f3d40cbf
@ -3599,7 +3599,7 @@ virDomainBlockStats (virDomainPtr dom, const char *path,
|
|||||||
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!stats || size > sizeof stats2) {
|
if (!path || !stats || size > sizeof stats2) {
|
||||||
virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -3657,7 +3657,7 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path,
|
|||||||
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!stats || size > sizeof stats2) {
|
if (!path || !stats || size > sizeof stats2) {
|
||||||
virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -5704,12 +5704,6 @@ qemudDomainInterfaceStats (virDomainPtr dom,
|
|||||||
goto cleanup;
|
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. */
|
/* Check the path is one of the domain's network interfaces. */
|
||||||
for (i = 0 ; i < vm->def->nnets ; i++) {
|
for (i = 0 ; i < vm->def->nnets ; i++) {
|
||||||
if (vm->def->nets[i]->ifname &&
|
if (vm->def->nets[i]->ifname &&
|
||||||
|
Loading…
Reference in New Issue
Block a user