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

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