From: Laine Stump Date: Sat, 20 Apr 2024 02:19:42 +0000 (-0400) Subject: util: check for 0 args when applying iptables rule X-Git-Tag: v10.4.0-rc1~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad96ee74ce080ebff18c9d0dfec24038ee86dd15;p=thirdparty%2Flibvirt.git util: check for 0 args when applying iptables rule 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 Reviewed-by: Daniel P. Berrangé --- diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 902cb8e445..1897a66070 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -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;