Blame SOURCES/0001-evmctl-fix-memory-leak-in-get_password.patch

96bd04
From 2f1740eab432abc8e85172531d97eba33342474c Mon Sep 17 00:00:00 2001
96bd04
From: Bruno Meneguele <bmeneg@redhat.com>
96bd04
Date: Mon, 16 Aug 2021 12:11:15 -0300
96bd04
Subject: [PATCH] evmctl: fix memory leak in get_password
96bd04
96bd04
The variable "password" is not freed nor returned in case get_password()
96bd04
succeeds. Return it instead of the intermediary variable "pwd". Issue found
96bd04
by Coverity scan tool.
96bd04
96bd04
src/evmctl.c:2565: leaked_storage: Variable "password" going out of scope
96bd04
    leaks the storage it points to.
96bd04
96bd04
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
96bd04
---
96bd04
 src/evmctl.c | 7 ++++++-
96bd04
 1 file changed, 6 insertions(+), 1 deletion(-)
96bd04
96bd04
diff --git a/src/evmctl.c b/src/evmctl.c
96bd04
index a8065bbe124a..ab7173723095 100644
96bd04
--- a/src/evmctl.c
96bd04
+++ b/src/evmctl.c
96bd04
@@ -2625,7 +2625,12 @@ static char *get_password(void)
96bd04
 		return NULL;
96bd04
 	}
96bd04
 
96bd04
-	return pwd;
96bd04
+	if (pwd == NULL) {
96bd04
+		free(password);
96bd04
+		return NULL;
96bd04
+	}
96bd04
+
96bd04
+	return password;
96bd04
 }
96bd04
 
96bd04
 int main(int argc, char *argv[])
96bd04
-- 
96bd04
2.31.1
96bd04