[Libvir] [PATCH]check NULL of mac

S.Sakamoto fj0588di at aa.jp.fujitsu.com
Tue Feb 26 08:26:26 UTC 2008


Hi,

"attach-device" become the segmentation fault,
when it uses following xml. (There is no "address='xx'")
+----------------------------------------------------+
|    <interface type='bridge'>                       |
|      <source bridge='xenbr0'/>                     |
|      <mac/>                                        |
|      <script path='/etc/xen/scripts/vif-bridge'/>  |
|    </interface>                                    |
+----------------------------------------------------+
Libxml gives back NULL when there is not an attribute. 
"xenXMAttachInterface" compares it in strcmp as NULL.

So, I make the patch which solved this problem.

Thanks,
Shigeki Sakamoto.


Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.64
diff -u -p -r1.64 xm_internal.c
--- src/xm_internal.c	20 Feb 2008 15:29:13 -0000	1.64
+++ src/xm_internal.c	26 Feb 2008 06:39:05 -0000
@@ -2769,12 +2769,13 @@ xenXMAttachInterface(virDomainPtr domain
     }
     source = xmlGetProp(node, BAD_CAST type);
 
-    if (!(node = virXPathNode("/interface/mac", ctxt))) {
+    if ((node = virXPathNode("/interface/mac", ctxt)))
+        mac = xmlGetProp(node, BAD_CAST "address");
+    if (!node || !mac) {
         if (!(mac = (xmlChar *)xenXMAutoAssignMac()))
             goto cleanup;
         autoassign = 1;
-    } else
-        mac = xmlGetProp(node, BAD_CAST "address");
+    }
 
     list_item = virConfGetValue(entry->conf, "vif");
     if (list_item && list_item->type == VIR_CONF_LIST) {




More information about the libvir-list mailing list