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

[Xen-changelog] [xen stable-4.2] libxl: fix fd check in libxl__spawn_local_dm



commit b8ef216d7605c1ceb59be838e9d16baa9e1e94fd
Author:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
AuthorDate: Fri Nov 22 12:54:08 2013 +0100
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Thu Jan 9 12:40:18 2014 +0000

    libxl: fix fd check in libxl__spawn_local_dm
    
    Checking the logfile_w fd for -1 on failure is no longer true, because
    libxl__create_qemu_logfile will now return ERROR_FAIL on failure which
    is -3.
    
    While there also add an error check for opening /dev/null.
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
    Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    (cherry picked from commit 3b88d95e9c0a5ff91d5b60e94d81f1982af57e7f)
    
    Conflicts:
        tools/libxl/libxl_dm.c
    (cherry picked from commit 8f1bd27fcd7f8be1353e7309f450283f3e5f7cd0)
    
    Conflicts:
        tools/libxl/libxl_dm.c
---
 tools/libxl/libxl_dm.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 80b4973..88a4894 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1122,6 +1122,11 @@ void libxl__spawn_local_dm(libxl__egc *egc, 
libxl__dm_spawn_state *dmss)
     logfile_w = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
     free(logfile);
     null = open("/dev/null", O_RDONLY);
+    if (null < 0) {
+        LOGE(ERROR, "unable to open /dev/null");
+        rc = ERROR_FAIL;
+        goto out_close;
+    }
 
     const char *dom_path = libxl__xs_get_dompath(gc, domid);
     spawn->pidpath = GCSPRINTF("%s/%s", dom_path, "image/device-model-pid");
@@ -1169,8 +1174,8 @@ retry_transaction:
     rc = 0;
 
 out_close:
-    close(null);
-    close(logfile_w);
+    if (null >= 0) close(null);
+    if (logfile_w >= 0) close(logfile_w);
     free(args);
 out:
     if (rc)
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.2

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.