]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: Ensure that bool --options don't have completer
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 17 Sep 2021 07:58:03 +0000 (09:58 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Sep 2021 08:20:41 +0000 (10:20 +0200)
Let's check whether a boolean --option doesn't have completer or
completer_flags set. These options are just flags and don't
accept any value, thus they can't have any completer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c

index dd6930730d097fa3d82cf0c30a48737314f89f51..e81369f224162ce09cf9f39f8d743d1de21acce4 100644 (file)
@@ -337,8 +337,16 @@ vshCmddefCheckInternals(vshControl *ctl,
             virBufferStrcat(&complbuf, opt->name, ", ", NULL);
 
         switch (opt->type) {
-        case VSH_OT_STRING:
         case VSH_OT_BOOL:
+            if (opt->completer || opt->completer_flags) {
+                vshError(ctl, _("bool parameter '%s' of command '%s' has completer set"),
+                         opt->name, cmd->name);
+                return -1;
+            }
+
+            G_GNUC_FALLTHROUGH;
+
+        case VSH_OT_STRING:
             if (opt->flags & VSH_OFLAG_REQ) {
                 vshError(ctl, _("parameter '%s' of command '%s' misused VSH_OFLAG_REQ"),
                          opt->name, cmd->name);