]> xenbits.xensource.com Git - libvirt.git/commitdiff
Make virsh -d check its input
authorDaniel Veillard <veillard@redhat.com>
Mon, 2 Aug 2010 19:20:26 +0000 (21:20 +0200)
committerDaniel Veillard <veillard@redhat.com>
Mon, 2 Aug 2010 19:20:26 +0000 (21:20 +0200)
it was using atoi direct without checking leading to confusion
in case of flag error for example with -c

* tools/virsh.c: vshParseArgv() use virStrToLong_i and remove the
  unchecked atoi used to parse teh parameter

tools/virsh.c

index 354feb0c29fd1a17dcd40221161c87bf653d897e..926652a26a0b6954cdc0e7843015144ab7903fd7 100644 (file)
@@ -11021,7 +11021,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
     while ((arg = getopt_long(end, argv, "d:hqtc:vrl:", opt, &idx)) != -1) {
         switch (arg) {
         case 'd':
-            ctl->debug = atoi(optarg);
+            if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
+                vshError(ctl, _("option -d takes a numeric argument"), arg);
+                exit(EXIT_FAILURE);
+            }
             break;
         case 'h':
             help = 1;