Blame SOURCES/0127-libmultipath-don-t-leak-memory-on-invalid-strings.patch

8b67ad
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8b67ad
From: Benjamin Marzinski <bmarzins@redhat.com>
8b67ad
Date: Wed, 14 Dec 2022 15:38:19 -0600
8b67ad
Subject: [PATCH] libmultipath: don't leak memory on invalid strings
8b67ad
8b67ad
If set_path() or set_str_noslash() are called with a bad value, they
8b67ad
ignore it and continue to use the old value. But they weren't freeing
8b67ad
the bad value, causing a memory leak.
8b67ad
8b67ad
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
8b67ad
Reviewed-by: Martin Wilck <mwilck@suse.com>
8b67ad
---
8b67ad
 libmultipath/dict.c | 2 ++
8b67ad
 1 file changed, 2 insertions(+)
8b67ad
8b67ad
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
8b67ad
index d7cd94a5..a8c9e989 100644
8b67ad
--- a/libmultipath/dict.c
8b67ad
+++ b/libmultipath/dict.c
8b67ad
@@ -169,6 +169,7 @@ set_path(vector strvec, void *ptr, const char *file, int line_nr)
8b67ad
 	if ((*str_ptr)[0] != '/'){
8b67ad
 		condlog(1, "%s line %d, %s is not an absolute path. Ignoring",
8b67ad
 			file, line_nr, *str_ptr);
8b67ad
+		free(*str_ptr);
8b67ad
 		*str_ptr = old_str;
8b67ad
 	} else
8b67ad
 		free(old_str);
8b67ad
@@ -189,6 +190,7 @@ set_str_noslash(vector strvec, void *ptr, const char *file, int line_nr)
8b67ad
 	if (strchr(*str_ptr, '/')) {
8b67ad
 		condlog(1, "%s line %d, %s cannot contain a slash. Ignoring",
8b67ad
 			file, line_nr, *str_ptr);
8b67ad
+		free(*str_ptr);
8b67ad
 		*str_ptr = old_str;
8b67ad
 	} else
8b67ad
 		free(old_str);