From 5c3be42813320b3a2ce9a34357754204212f03dd Mon Sep 17 00:00:00 2001 From: Ben Gray Date: Sat, 23 Apr 2016 18:38:21 -0400 Subject: [PATCH] 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 (cherry picked from commit 5ba48584fbc5079c0ddbc9e9a52c96d7bcef0761) --- src/rpc/virnetclient.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index d0b96b654f..48da767c74 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1176,6 +1176,7 @@ virNetClientIOWriteMessage(virNetClientPtr client, if (rv == 0) /* Blocking */ return 0; thecall->msg->donefds++; + VIR_FORCE_CLOSE(thecall->msg->fds[i]); } thecall->msg->donefds = 0; thecall->msg->bufferOffset = thecall->msg->bufferLength = 0; -- 2.47.2