[libvirt] [PATCH] Avoid a libvirtd crash on broken input 523418

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

 



  A simple typo in an XML domain file could lead to a crash, because
we called STRPREFIX() on the looked up value without checking it was
non-null. Patch is trivial, and should go in but I wonder if we
shouldn't make those STR macros safer too like turning

#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)

into

#define STRPREFIX(a,b) ((a) && (b) && (strncmp((a),(b),strlen((b))) == 0))

anyway I think we should apply the patch independently, without it
libvirtd crash, with it we get the proper error report:

[root@paphio ~]# virsh define RHEL-5.4-64.xml
18:32:21.982: warning : processCallDispatchReply:7570 : Method call
error
error: Failed to define domain from RHEL-5.4-64.xml
error: internal error No <source> 'dev' attribute specified with
<interface type='bridge'/>

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 868e865..9cf0af1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1032,7 +1032,8 @@ virDomainNetDefParseXML(virConnectPtr conn,
             } else if ((ifname == NULL) &&
                        xmlStrEqual(cur->name, BAD_CAST "target")) {
                 ifname = virXMLPropString(cur, "dev");
-                if (STRPREFIX((const char*)ifname, "vnet")) {
+                if ((ifname != NULL) &&
+                    (STRPREFIX((const char*)ifname, "vnet"))) {
                     /* An auto-generated target name, blank it out */
                     VIR_FREE(ifname);
                 }
--
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]