]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-domain: Report errors on invalid --holdtime value for cmdSendKey
authorPeter Krempa <pkrempa@redhat.com>
Thu, 18 Apr 2013 08:42:47 +0000 (10:42 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 18 Apr 2013 13:23:09 +0000 (15:23 +0200)
Using of a incorrect value for the --holdtime option was silently
ignored and 0 was used. In case a negative number was used, it
overflowed as the API expects a unsigned int.

Fix the data type and getter function type and report errors on
incorrect values.

tools/virsh-domain.c

index 02555426a12a62e8e5cac4729b0f527436ae02f7..4652914780f48eb085e965b7100d8feae257053e 100644 (file)
@@ -6741,7 +6741,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
     int ret = false;
     const char *codeset_option;
     int codeset;
-    int holdtime;
+    unsigned int holdtime = 0;
     int count = 0;
     const vshCmdOpt *opt = NULL;
     int keycode;
@@ -6753,8 +6753,10 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptString(cmd, "codeset", &codeset_option) <= 0)
         codeset_option = "linux";
 
-    if (vshCommandOptInt(cmd, "holdtime", &holdtime) <= 0)
-        holdtime = 0;
+    if (vshCommandOptUInt(cmd, "holdtime", &holdtime) < 0) {
+        vshError(ctl, _("invalid value of --holdtime"));
+        goto cleanup;
+    }
 
     codeset = virKeycodeSetTypeFromString(codeset_option);
     if (codeset < 0) {