mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-08 14:29:56 +00:00
Fix crash on OOM in qemuAddRBDHost
When parsing the RBD hosts, it increments the 'nhosts' counter before increasing the 'hosts' array allocation. If an OOM then occurs when increasing the array allocation, the cleanup block will attempt to access beyond the end of the array. Switch to using VIR_EXPAND_N instead of VIR_REALLOC_N to protect against this mistake Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
ba19783d9b
commit
0bea528a33
@ -3232,9 +3232,8 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
|
|||||||
size_t skip;
|
size_t skip;
|
||||||
char **parts;
|
char **parts;
|
||||||
|
|
||||||
disk->nhosts++;
|
if (VIR_EXPAND_N(disk->hosts, disk->nhosts, 1) < 0)
|
||||||
if (VIR_REALLOC_N(disk->hosts, disk->nhosts) < 0)
|
return -1;
|
||||||
goto error;
|
|
||||||
|
|
||||||
if ((port = strchr(hostport, ']'))) {
|
if ((port = strchr(hostport, ']'))) {
|
||||||
/* ipv6, strip brackets */
|
/* ipv6, strip brackets */
|
||||||
|
Loading…
Reference in New Issue
Block a user