]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: check for 0 args when applying iptables rule
authorLaine Stump <laine@redhat.com>
Sat, 20 Apr 2024 02:19:42 +0000 (22:19 -0400)
committerLaine Stump <laine@redhat.com>
Thu, 23 May 2024 03:19:18 +0000 (23:19 -0400)
In normal practice a virFirewallCmd should never have 0 args by the
time it gets to the Apply stage, but at some time while debugging one
of the other patches in this series, exactly that happened (due to a
bug that was since squashed), and having a check for it helped
debugging, so let's permanently check for it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virfirewall.c

index 902cb8e4457a00a14ccb4145ea55ce14997ccdb5..1897a66070764ee62801c5ecda79665e36453955 100644 (file)
@@ -538,6 +538,12 @@ virFirewallApplyCmd(virFirewall *firewall,
     if (fwCmd->ignoreErrors)
         ignoreErrors = fwCmd->ignoreErrors;
 
+    if (fwCmd->argsLen == 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Can't apply empty firewall command"));
+        return -1;
+    }
+
     if (virFirewallApplyCmdDirect(fwCmd, ignoreErrors, &output) < 0)
         return -1;