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

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

  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)


#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: Failed to define domain from RHEL-5.4-64.xml
error: internal error No <source> 'dev' attribute specified with
<interface type='bridge'/>


Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | 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 */

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