WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl: fixup "xl save" command line handling
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 13 Sep 2011 15:06:50 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Tue, 13 Sep 2011 07:09:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# 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

<Prev in Thread] Current Thread [Next in Thread>