[PATCH] Fix format string handling in network driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 8da28e4..327bb08 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1601,11 +1601,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;
     }
 
@@ -1617,11 +1619,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;
     }
 
@@ -1633,11 +1637,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;
     }
 
-- 
1.8.2.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]