From: Ian Campbell Date: Tue, 27 Sep 2011 16:32:16 +0000 (+0100) Subject: xl: fixup "xl save" command line handling. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~9860 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=af785dee41395dbf3b76ce47f7e9339976c10d55;p=xen.git 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 Acked-by: Ian Jackson Committed-by: Ian Jackson --- diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 10a38c8520..fb6497bf57 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2856,8 +2856,8 @@ int main_migrate_receive(int argc, char **argv) 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; }