Blame SOURCES/bz1766995-fence_virtd-1-fix-segfault-no-domains.patch

fb144c
From 36367a99eb803a7941f6cbfd6086e7a71bf91e21 Mon Sep 17 00:00:00 2001
fb144c
From: Andrew Price <anprice@redhat.com>
fb144c
Date: Tue, 29 Oct 2019 11:27:06 +0000
fb144c
Subject: [PATCH] fence_virtd: Fix segfault in vl_get when no domains are found
fb144c
fb144c
If virConnectListAllDomains() returns 0 on every iteration, the loop
fb144c
will end with a vl == NULL and the pointer dereference in the qsort()
fb144c
call will result in a segfault. Check for NULL on completion of the loop
fb144c
to guard against that.
fb144c
fb144c
Signed-off-by: Andrew Price <anprice@redhat.com>
fb144c
---
fb144c
 server/virt.c | 3 +++
fb144c
 1 file changed, 3 insertions(+)
fb144c
fb144c
diff --git a/server/virt.c b/server/virt.c
fb144c
index 9710791..ed08e0c 100644
fb144c
--- a/server/virt.c
fb144c
+++ b/server/virt.c
fb144c
@@ -128,6 +128,9 @@ virt_list_t *vl_get(virConnectPtr *vp, int vp_count, int my_id)
fb144c
 
fb144c
 		_free_dom_list(dom_list, ret);
fb144c
 	}
fb144c
+	/* No domains found */
fb144c
+	if (!vl)
fb144c
+		return NULL;
fb144c
 
fb144c
 	/* We have all the locally running domains & states now */
fb144c
 	/* Sort */