mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-07 04:07:17 +00:00
rpc: Don't leak fd via CreateXMLWithFiles
FD passing APIs like CreateXMLWithFiles or OpenGraphicsFD will leak file descriptors. The user passes in an fd, which is dup()'d in virNetClientProgramCall. The new fd is what is transfered to the server virNetClientIOWriteMessage. Once all the fds have been written though, the parent msg->fds list is immediately free'd, so the individual fds are never closed. This closes each FD as its send to the server, so all fds have been closed by the time msg->fds is free'd. https://bugzilla.redhat.com/show_bug.cgi?id=1159766
This commit is contained in:
parent
cdbbb93a96
commit
5ba48584fb
@ -1184,6 +1184,7 @@ virNetClientIOWriteMessage(virNetClientPtr client,
|
|||||||
if (rv == 0) /* Blocking */
|
if (rv == 0) /* Blocking */
|
||||||
return 0;
|
return 0;
|
||||||
thecall->msg->donefds++;
|
thecall->msg->donefds++;
|
||||||
|
VIR_FORCE_CLOSE(thecall->msg->fds[i]);
|
||||||
}
|
}
|
||||||
thecall->msg->donefds = 0;
|
thecall->msg->donefds = 0;
|
||||||
thecall->msg->bufferOffset = thecall->msg->bufferLength = 0;
|
thecall->msg->bufferOffset = thecall->msg->bufferLength = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user