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

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