Blame SOURCES/0095-libmultipath-steal-the-src-string-pointer-in-merge_s.patch

c90e5b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
c90e5b
From: Benjamin Marzinski <bmarzins@redhat.com>
c90e5b
Date: Wed, 13 Apr 2022 23:27:35 -0500
c90e5b
Subject: [PATCH] libmultipath: steal the src string pointer in merge_str()
c90e5b
c90e5b
Instead of allocating a copy when the original string is going to be
c90e5b
freed right after the merge, just steal the pointer. Also, merge_mpe()
c90e5b
can't get called with NULL arguments.
c90e5b
c90e5b
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
c90e5b
Reviewed-by: Martin Wilck <mwilck@suse.com>
c90e5b
---
c90e5b
 libmultipath/config.c | 16 +++++-----------
c90e5b
 1 file changed, 5 insertions(+), 11 deletions(-)
c90e5b
c90e5b
diff --git a/libmultipath/config.c b/libmultipath/config.c
c90e5b
index abbddaf1..aa79561e 100644
c90e5b
--- a/libmultipath/config.c
c90e5b
+++ b/libmultipath/config.c
c90e5b
@@ -323,9 +323,9 @@ set_param_str(const char * str)
c90e5b
 }
c90e5b
 
c90e5b
 #define merge_str(s) \
c90e5b
-	if (!dst->s && src->s) { \
c90e5b
-		if (!(dst->s = set_param_str(src->s))) \
c90e5b
-			return 1; \
c90e5b
+	if (!dst->s && src->s && strlen(src->s)) { \
c90e5b
+		dst->s = src->s; \
c90e5b
+		src->s = NULL; \
c90e5b
 	}
c90e5b
 
c90e5b
 #define merge_num(s) \
c90e5b
@@ -333,7 +333,7 @@ set_param_str(const char * str)
c90e5b
 		dst->s = src->s
c90e5b
 
c90e5b
 
c90e5b
-static int
c90e5b
+static void
c90e5b
 merge_hwe (struct hwentry * dst, struct hwentry * src)
c90e5b
 {
c90e5b
 	char id[SCSI_VENDOR_SIZE+PATH_PRODUCT_SIZE];
c90e5b
@@ -385,15 +385,11 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)
c90e5b
 	reconcile_features_with_options(id, &dst->features,
c90e5b
 					&dst->no_path_retry,
c90e5b
 					&dst->retain_hwhandler);
c90e5b
-	return 0;
c90e5b
 }
c90e5b
 
c90e5b
-static int
c90e5b
+static void
c90e5b
 merge_mpe(struct mpentry *dst, struct mpentry *src)
c90e5b
 {
c90e5b
-	if (!dst || !src)
c90e5b
-		return 1;
c90e5b
-
c90e5b
 	merge_str(alias);
c90e5b
 	merge_str(uid_attribute);
c90e5b
 	merge_str(getuid);
c90e5b
@@ -435,8 +431,6 @@ merge_mpe(struct mpentry *dst, struct mpentry *src)
c90e5b
 	merge_num(uid);
c90e5b
 	merge_num(gid);
c90e5b
 	merge_num(mode);
c90e5b
-
c90e5b
-	return 0;
c90e5b
 }
c90e5b
 
c90e5b
 void merge_mptable(vector mptable)