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

[Xen-devel] [PATCH] libxl: do not leak path to dom0 attached disk after running bootloader



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1282552566 -3600
# Node ID 79f44934fa9dbf56d60a6d9fb76b74081eafe75f
# Parent  e0d61de332ccdf86bde2abcb2298678d3c9f937c
libxl: do not leak path to dom0 attached disk after running bootloader

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r e0d61de332cc -r 79f44934fa9d tools/libxl/libxl_bootloader.c
--- a/tools/libxl/libxl_bootloader.c    Mon Aug 23 09:30:06 2010 +0100
+++ b/tools/libxl/libxl_bootloader.c    Mon Aug 23 09:36:06 2010 +0100
@@ -33,7 +33,7 @@ static char **make_bootloader_args(libxl
 static char **make_bootloader_args(libxl_gc *gc,
                                    libxl_domain_build_info *info,
                                    uint32_t domid,
-                                   const char *fifo, const char *disk)
+                                   const char *fifo, char *disk)
 {
     flexarray_t *args;
     int nr = 0;
@@ -65,7 +65,7 @@ static char **make_bootloader_args(libxl
         } while ((t = strtok_r(NULL, " \t\n", &saveptr)));
     }
 
-    flexarray_set(args, nr++, strdup(disk));
+    flexarray_set(args, nr++, disk);
 
     /* Sentinal for execv */
     flexarray_set(args, nr++, NULL);
@@ -303,7 +303,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
     libxl_gc gc = LIBXL_INIT_GC(ctx);
     int ret, rc = 0;
     char *fifo = NULL;
-    const char *diskpath = NULL;
+    char *diskpath = NULL;
     char **args = NULL;
 
     char tempdir_template[] = "/var/run/libxl/bl.XXXXXX";
@@ -414,12 +414,14 @@ int libxl_run_bootloader(libxl_ctx *ctx,
         goto out_close;
     }
 
-    libxl_device_disk_local_detach(ctx, disk);
-
     parse_bootloader_result(ctx, info, blout);
 
     rc = 0;
 out_close:
+    if (diskpath) {
+        libxl_device_disk_local_detach(ctx, disk);
+        free(diskpath);
+    }
     if (fifo_fd > -1)
         close(fifo_fd);
     if (bootloader_fd > -1)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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