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

[Xen-devel] [PATCH] xl: fixup "xl save" command line handling



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1315922772 -3600
# Node ID 311080019e01809614dac0321b210ef1a9bbcb44
# Parent  4309ff9535001bdca8db93a439edd86bb4c447cd
xl: fixup "xl save" command line handling.

The save file paramter is required so ensure we have enough arguments.

The config filename is optional so do not use argv[optind+3], which
may well happen to be NULL when the paramter is not present but
relying on that is pretty gross.

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

diff -r 4309ff953500 -r 311080019e01 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Sep 01 17:34:41 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue Sep 13 15:06:12 2011 +0100
@@ -2856,8 +2856,8 @@ int main_migrate_receive(int argc, char 
 
 int main_save(int argc, char **argv)
 {
-    const char *filename = NULL, *p = NULL;
-    const char *config_filename;
+    const char *filename, *p;
+    const char *config_filename = NULL;
     int checkpoint = 0;
     int opt;
 
@@ -2871,14 +2871,16 @@ int main_save(int argc, char **argv)
         }
     }
 
-    if (argc-optind > 3) {
+    if (argc-optind < 2 || argc-optind > 3) {
         help("save");
         return 2;
     }
 
     p = argv[optind];
     filename = argv[optind + 1];
-    config_filename = argv[optind + 2];
+    if ( argc - optind >= 3 )
+        config_filename = argv[optind + 2];
+
     save_domain(p, filename, checkpoint, config_filename);
     return 0;
 }

_______________________________________________
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®.