mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
uml: avoid crash on partial read
Coverity detected a potential dereference of uninitialized memory if recvfrom got cut short. * src/uml/uml_driver.c (umlMonitorCommand): Validate complete read prior to dereferencing res.
This commit is contained in:
parent
2103d87c89
commit
4acbb29821
@ -733,14 +733,24 @@ static int umlMonitorCommand(virConnectPtr conn,
|
||||
}
|
||||
|
||||
do {
|
||||
ssize_t nbytes;
|
||||
addrlen = sizeof(addr);
|
||||
if (recvfrom(priv->monitor, &res, sizeof res, 0,
|
||||
(struct sockaddr *)&addr, &addrlen) < 0) {
|
||||
nbytes = recvfrom(priv->monitor, &res, sizeof res, 0,
|
||||
(struct sockaddr *)&addr, &addrlen) < 0;
|
||||
if (nbytes < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
continue;
|
||||
virReportSystemError(errno,
|
||||
_("cannot read reply %s"),
|
||||
cmd);
|
||||
goto error;
|
||||
}
|
||||
if (nbytes < sizeof res) {
|
||||
virReportSystemError(errno,
|
||||
_("incomplete reply %s"),
|
||||
cmd);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (VIR_REALLOC_N(retdata, retlen + res.length) < 0) {
|
||||
virReportOOMError();
|
||||
|
Loading…
x
Reference in New Issue
Block a user