mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-11 04:15:49 +00:00
qemuDomainGetGuestInfo: Don't try to free a negative number of entries
'nfs' variable was set to -1 or -2 on agent failure. Cleanup then tried
to free 'nfs' elements of the array which resulted into a crash.
Make 'nfs' size_t and assign it only on successful agent call.
https://bugzilla.redhat.com/show_bug.cgi?id=1812965
Broken by commit 599ae372d8
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
da1b193227
commit
0fdb7385e4
@ -1941,7 +1941,7 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns: 0 on success
|
/* Returns: number of entries in '@info' on success
|
||||||
* -2 when agent command is not supported by the agent
|
* -2 when agent command is not supported by the agent
|
||||||
* -1 otherwise
|
* -1 otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -22814,7 +22814,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
|
|||||||
g_autofree char *hostname = NULL;
|
g_autofree char *hostname = NULL;
|
||||||
unsigned int supportedTypes = types;
|
unsigned int supportedTypes = types;
|
||||||
int rc;
|
int rc;
|
||||||
int nfs = 0;
|
size_t nfs = 0;
|
||||||
qemuAgentFSInfoPtr *agentfsinfo = NULL;
|
qemuAgentFSInfoPtr *agentfsinfo = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -22867,9 +22867,13 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
|
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
|
||||||
rc = nfs = qemuAgentGetFSInfo(agent, &agentfsinfo);
|
rc = qemuAgentGetFSInfo(agent, &agentfsinfo);
|
||||||
if (rc < 0 && !(rc == -2 && types == 0))
|
if (rc < 0) {
|
||||||
goto exitagent;
|
if (!(rc == -2 && types == 0))
|
||||||
|
goto exitagent;
|
||||||
|
} else {
|
||||||
|
nfs = rc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user