[libvirt] [PATCH 03/23] Don't clobber return value in virInterfaceDefParseProtoIPv6

Daniel P. Berrange berrange at redhat.com
Wed Sep 25 14:50:58 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

Several places in virInterfaceDefParseProtoIPv6 clobber the
default 'ret' return value. So when jumping to cleanup on
error, 'ret' may mistakenly be set to 0 instead of -1. This
caused failure to report OOM errors, meaning data was silently
lost during parsing.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/conf/interface_conf.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 19d0327..79aab6e 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -309,9 +309,8 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
 
     dhcp = virXPathNode("./dhcp", ctxt);
     if (dhcp != NULL) {
-        ret = virInterfaceDefParseDhcp(def, dhcp, ctxt);
-        if (ret != 0)
-           return ret;
+        if (virInterfaceDefParseDhcp(def, dhcp, ctxt) < 0)
+            return -1;
     }
 
     nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);
@@ -332,8 +331,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
             goto error;
 
         ctxt->node = ipNodes[i];
-        ret = virInterfaceDefParseIp(ip, ctxt);
-        if (ret != 0) {
+        if (virInterfaceDefParseIp(ip, ctxt) < 0) {
             virInterfaceIpDefFree(ip);
             goto error;
         }
@@ -365,9 +363,8 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
 
     dhcp = virXPathNode("./dhcp", ctxt);
     if (dhcp != NULL) {
-        ret = virInterfaceDefParseDhcp(def, dhcp, ctxt);
-        if (ret != 0)
-           return ret;
+        if (virInterfaceDefParseDhcp(def, dhcp, ctxt) < 0)
+            return -1;
     }
 
     nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);
@@ -388,8 +385,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
             goto error;
 
         ctxt->node = ipNodes[i];
-        ret = virInterfaceDefParseIp(ip, ctxt);
-        if (ret != 0) {
+        if (virInterfaceDefParseIp(ip, ctxt) < 0) {
             virInterfaceIpDefFree(ip);
             goto error;
         }
-- 
1.8.3.1




More information about the libvir-list mailing list