mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
libvir.c: avoid NULL dereference in virStoragePoolSetAutostart
* src/libvirt.c (virStoragePoolSetAutostart): Return -1 if the pool argument is invalid, rather than "goto error" where we could dereference that possibly-NULL "pool". (virConnectFindStoragePoolSources): Likewise. (virConnectNumOfDomains): Likewise. Daniel P. Berrange spotted that the two latter functions needed the same treatment.
This commit is contained in:
parent
1f5e292520
commit
d9b4538469
@ -1606,7 +1606,7 @@ virConnectNumOfDomains(virConnectPtr conn)
|
|||||||
|
|
||||||
if (!VIR_IS_CONNECT(conn)) {
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->driver->numOfDomains) {
|
if (conn->driver->numOfDomains) {
|
||||||
@ -6451,7 +6451,7 @@ virConnectFindStoragePoolSources(virConnectPtr conn,
|
|||||||
|
|
||||||
if (!VIR_IS_CONNECT(conn)) {
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
@ -7339,7 +7339,7 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
|
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
|
||||||
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
|
virLibStoragePoolError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pool->conn->flags & VIR_CONNECT_RO) {
|
if (pool->conn->flags & VIR_CONNECT_RO) {
|
||||||
|
Loading…
Reference in New Issue
Block a user