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

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