[PATCH] command: avoid double close in virExecWithHook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix possible double close in the child process after the fork in case
infd and outfd are equal, just like they are after being called from
virNetSocketNewConnectCommand.
---
 src/util/command.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/util/command.c b/src/util/command.c
index 7755572..49ec178 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -547,17 +547,13 @@ virExecWithHook(const char *const*argv,
         goto fork_error;
     }
 
-    if (infd != STDIN_FILENO && infd != null)
+    if (infd != STDIN_FILENO && infd != null && infd != childerr &&
+        infd != childout)
         VIR_FORCE_CLOSE(infd);
-    if (childout > STDERR_FILENO && childout != null) {
-        tmpfd = childout;   /* preserve childout value */
-        VIR_FORCE_CLOSE(tmpfd);
-    }
-    if (childerr > STDERR_FILENO &&
-        childerr != childout &&
-        childerr != null) {
+    if (childout > STDERR_FILENO && childout != null && childout != childerr)
+        VIR_FORCE_CLOSE(childout);
+    if (childerr > STDERR_FILENO && childerr != null)
         VIR_FORCE_CLOSE(childerr);
-    }
     VIR_FORCE_CLOSE(null);
 
     /* Initialize full logging for a while */
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]