summaryrefslogtreecommitdiffstats
path: root/daemon/guestfsd.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-20 11:35:57 +0100
committerRichard Jones <rjones@redhat.com>2009-04-20 11:35:57 +0100
commit2069ade88144d8efd272a74be24b5c9ff49844dc (patch)
tree0057e2583218c7edc88f64c52870c94fc165fddb /daemon/guestfsd.c
parent24ccbb29ac475187f51a27dcd318db2b4824a0c1 (diff)
downloadlibguestfs-2069ade88144d8efd272a74be24b5c9ff49844dc.tar.gz
libguestfs-2069ade88144d8efd272a74be24b5c9ff49844dc.tar.xz
libguestfs-2069ade88144d8efd272a74be24b5c9ff49844dc.zip
Fix file descriptor leak in daemon.
Diffstat (limited to 'daemon/guestfsd.c')
-rw-r--r--daemon/guestfsd.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 2553ea2c..a9576836 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -384,6 +384,10 @@ commandv (char **stdoutput, char **stderror, char * const* const argv)
pid = fork ();
if (pid == -1) {
perror ("fork");
+ close (so_fd[0]);
+ close (so_fd[1]);
+ close (se_fd[0]);
+ close (se_fd[1]);
return -1;
}
@@ -415,6 +419,8 @@ commandv (char **stdoutput, char **stderror, char * const* const argv)
r = select (MAX (so_fd[0], se_fd[0]) + 1, &rset2, NULL, NULL, NULL);
if (r == -1) {
perror ("select");
+ close (so_fd[0]);
+ close (se_fd[0]);
waitpid (pid, NULL, 0);
return -1;
}
@@ -423,6 +429,8 @@ commandv (char **stdoutput, char **stderror, char * const* const argv)
r = read (so_fd[0], buf, sizeof buf);
if (r == -1) {
perror ("read");
+ close (so_fd[0]);
+ close (se_fd[0]);
waitpid (pid, NULL, 0);
return -1;
}
@@ -444,6 +452,8 @@ commandv (char **stdoutput, char **stderror, char * const* const argv)
r = read (se_fd[0], buf, sizeof buf);
if (r == -1) {
perror ("read");
+ close (so_fd[0]);
+ close (se_fd[0]);
waitpid (pid, NULL, 0);
return -1;
}
@@ -462,6 +472,9 @@ commandv (char **stdoutput, char **stderror, char * const* const argv)
}
}
+ close (so_fd[0]);
+ close (se_fd[0]);
+
/* Make sure the output buffers are \0-terminated. Also remove any
* trailing \n characters from the error buffer (not from stdout).
*/