Blame SOURCES/libvirt-virDomainConfNWFilterInstantiate-initialize-xml-to-avoid-random-crash.patch

982648
From d39f6ba78035adbe3772603a1939af1e67464448 Mon Sep 17 00:00:00 2001
982648
Message-Id: <d39f6ba78035adbe3772603a1939af1e67464448@dist-git>
982648
From: Luyao Huang <lhuang@redhat.com>
982648
Date: Wed, 11 Jul 2018 17:29:48 +0200
982648
Subject: [PATCH] virDomainConfNWFilterInstantiate: initialize @xml to avoid
982648
 random crash
982648
MIME-Version: 1.0
982648
Content-Type: text/plain; charset=UTF-8
982648
Content-Transfer-Encoding: 8bit
982648
982648
https://bugzilla.redhat.com/show_bug.cgi?id=1599545
982648
982648
If the code jump to the cleanup before assigning value to @xml
982648
libvirtd may crash when it tries to free an uninitialized pointer.
982648
982648
backtrace:
982648
982648
0  0x00007ffff428d59c in free () from /lib64/libc.so.6
982648
1  0x00007ffff721314a in virFree (ptrptr=ptrptr@entry=0x7fffc67f1b00) at util/viralloc.c:582
982648
2  0x00007ffff7345ac4 in virDomainConfNWFilterInstantiate (vmname=<optimized out>,
982648
   vmuuid=vmuuid@entry=0x7fffc0181ca8 "߉\237\\۔H\262\206z\340\302f\265\233z", net=<optimized out>,
982648
   ignoreExists=ignoreExists@entry=true) at conf/domain_nwfilter.c:122
982648
3  0x00007fffca5a77f6 in qemuProcessFiltersInstantiate (ignoreExists=true, def=0x7fffc0181ca0) at qemu/qemu_process.c:3028
982648
4  qemuProcessReconnect (opaque=<optimized out>) at qemu/qemu_process.c:7653
982648
5  0x00007ffff72c4895 in virThreadHelper (data=<optimized out>) at util/virthread.c:206
982648
6  0x00007ffff45dcdd5 in start_thread () from /lib64/libpthread.so.0
982648
7  0x00007ffff4305ead in clone () from /lib64/libc.so.6
982648
982648
Signed-off-by: Luyao Huang <lhuang@redhat.com>
982648
(cherry picked from commit d7557f5f6f51264c1b5623e97f7b4d5259d4d3b6)
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
Reviewed-by: Ján Tomko <jtomko@redhat.com>
982648
---
982648
 src/conf/domain_nwfilter.c | 2 +-
982648
 1 file changed, 1 insertion(+), 1 deletion(-)
982648
982648
diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c
982648
index 948b32481e..24b5f42ddd 100644
982648
--- a/src/conf/domain_nwfilter.c
982648
+++ b/src/conf/domain_nwfilter.c
982648
@@ -90,7 +90,7 @@ virDomainConfNWFilterInstantiate(const char *vmname,
982648
     virConnectPtr conn = virGetConnectNWFilter();
982648
     virNWFilterBindingDefPtr def = NULL;
982648
     virNWFilterBindingPtr binding = NULL;
982648
-    char *xml;
982648
+    char *xml = NULL;
982648
     int ret = -1;
982648
 
982648
     VIR_DEBUG("vmname=%s portdev=%s filter=%s ignoreExists=%d",
982648
-- 
982648
2.18.0
982648