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