]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix format string handling in network driver
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 2 May 2013 11:33:55 +0000 (12:33 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 3 May 2013 09:29:07 +0000 (10:29 +0100)
The call to virReportError conditionally switched between
two format strings, with different numbers of placeholders.
This meant the format string with no placeholders was not
protected by a "%s".

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/network/bridge_driver.c

index 3ddea18d2b59ed9b00bbc5943bb7c170066d2644..e828997fa8b44f53c13c1ed44dab2b3e0a03d326 100644 (file)
@@ -1598,11 +1598,13 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver,
                                      &network->def->forward.addr,
                                      &network->def->forward.port,
                                      NULL) < 0) {
-        virReportError(VIR_ERR_SYSTEM_ERROR,
-                       forwardIf ?
-                       _("failed to add iptables rule to enable masquerading to %s") :
-                       _("failed to add iptables rule to enable masquerading"),
-                       forwardIf);
+        if (forwardIf)
+            virReportError(VIR_ERR_SYSTEM_ERROR,
+                           _("failed to add iptables rule to enable masquerading to %s"),
+                           forwardIf);
+        else
+            virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+                           _("failed to add iptables rule to enable masquerading"));
         goto masqerr3;
     }
 
@@ -1614,11 +1616,13 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver,
                                      &network->def->forward.addr,
                                      &network->def->forward.port,
                                      "udp") < 0) {
-        virReportError(VIR_ERR_SYSTEM_ERROR,
-                       forwardIf ?
-                       _("failed to add iptables rule to enable UDP masquerading to %s") :
-                       _("failed to add iptables rule to enable UDP masquerading"),
-                       forwardIf);
+        if (forwardIf)
+            virReportError(VIR_ERR_SYSTEM_ERROR,
+                           _("failed to add iptables rule to enable UDP masquerading to %s"),
+                           forwardIf);
+        else
+            virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+                           _("failed to add iptables rule to enable UDP masquerading"));
         goto masqerr4;
     }
 
@@ -1630,11 +1634,13 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver,
                                      &network->def->forward.addr,
                                      &network->def->forward.port,
                                      "tcp") < 0) {
-        virReportError(VIR_ERR_SYSTEM_ERROR,
-                       forwardIf ?
-                       _("failed to add iptables rule to enable TCP masquerading to %s") :
-                       _("failed to add iptables rule to enable TCP masquerading"),
-                       forwardIf);
+        if (forwardIf)
+            virReportError(VIR_ERR_SYSTEM_ERROR,
+                           _("failed to add iptables rule to enable TCP masquerading to %s"),
+                           forwardIf);
+        else
+            virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+                           _("failed to add iptables rule to enable TCP masquerading"));
         goto masqerr5;
     }