Blame SOURCES/0048-toollib-fix-segfault-when-handling-selection-with-hi.patch

ab86b0
From 45a2ccfa3bdf4c5b3f8b9e0cc5330fca345b0d26 Mon Sep 17 00:00:00 2001
ab86b0
From: Peter Rajnoha <prajnoha@redhat.com>
ab86b0
Date: Thu, 5 May 2022 11:02:32 +0200
ab86b0
Subject: [PATCH 48/54] toollib: fix segfault when handling selection with
ab86b0
 historical LVs
ab86b0
ab86b0
When processing historical LVs inside process_each_lv_in_vg for
ab86b0
selection, we need to use dummy "_historical_lv" for select_match_lv.
ab86b0
ab86b0
This is because a historical LV is not an actual LV, but only a tiny
ab86b0
representation with subset of original properties that we recorded
ab86b0
(name, uuid...).
ab86b0
ab86b0
To use the same processing functions we use for full-fledged non-historical
ab86b0
LVs, we need to use the prefilled "_historical_lv" structure which has all
ab86b0
the other missing properties hard-coded.
ab86b0
---
ab86b0
 tools/toollib.c | 7 ++++---
ab86b0
 1 file changed, 4 insertions(+), 3 deletions(-)
ab86b0
ab86b0
diff --git a/tools/toollib.c b/tools/toollib.c
ab86b0
index 697baee82..01ba03658 100644
ab86b0
--- a/tools/toollib.c
ab86b0
+++ b/tools/toollib.c
ab86b0
@@ -3392,13 +3392,14 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
ab86b0
 				process_lv = 1;
ab86b0
 			}
ab86b0
 
ab86b0
-			process_lv = process_lv && select_match_lv(cmd, handle, vg, lvl->lv) && _select_matches(handle);
ab86b0
+			_historical_lv.this_glv = glvl->glv;
ab86b0
+			_historical_lv.name = glvl->glv->historical->name;
ab86b0
+
ab86b0
+			process_lv = process_lv && select_match_lv(cmd, handle, vg, &_historical_lv) && _select_matches(handle);
ab86b0
 
ab86b0
 			if (!process_lv)
ab86b0
 				continue;
ab86b0
 
ab86b0
-			_historical_lv.this_glv = glvl->glv;
ab86b0
-			_historical_lv.name = glvl->glv->historical->name;
ab86b0
 			log_very_verbose("Processing historical LV %s in VG %s.", glvl->glv->historical->name, vg->name);
ab86b0
 
ab86b0
 			ret = process_single_lv(cmd, &_historical_lv, handle);
ab86b0
-- 
ab86b0
2.34.3
ab86b0