All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 ima-evm-utils] evmctl: fix memory leak in get_password
@ 2021-08-16 15:15 Bruno Meneguele
  2021-08-16 15:16 ` Bruno Meneguele
  0 siblings, 1 reply; 2+ messages in thread
From: Bruno Meneguele @ 2021-08-16 15:15 UTC (permalink / raw)
  To: vt, zohar, kgold; +Cc: linux-integrity, Bruno Meneguele

The variable "password" is not freed nor returned in case get_password()
succeeds. Return it instead of the intermediary variable "pwd". Issue found
by Coverity scan tool.

src/evmctl.c:2565: leaked_storage: Variable "password" going out of scope
    leaks the storage it points to.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
---
Changelog:
  v1: instead of removing the 'pwd' var, return 'password' (Mimi)

 src/evmctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index a8065bbe124a..ab7173723095 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -2625,7 +2625,12 @@ static char *get_password(void)
 		return NULL;
 	}
 
-	return pwd;
+	if (pwd == NULL) {
+		free(password);
+		return NULL;
+	}
+
+	return password;
 }
 
 int main(int argc, char *argv[])
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v2 ima-evm-utils] evmctl: fix memory leak in get_password
  2021-08-16 15:15 [PATCH v2 ima-evm-utils] evmctl: fix memory leak in get_password Bruno Meneguele
@ 2021-08-16 15:16 ` Bruno Meneguele
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Meneguele @ 2021-08-16 15:16 UTC (permalink / raw)
  To: vt, zohar, kgold; +Cc: linux-integrity, Bruno Meneguele

The variable "password" is not freed nor returned in case get_password()
succeeds. Return it instead of the intermediary variable "pwd". Issue found
by Coverity scan tool.

src/evmctl.c:2565: leaked_storage: Variable "password" going out of scope
    leaks the storage it points to.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
---
Changelog:
  v1: instead of removing the 'pwd' var, return 'password' (Mimi)

 src/evmctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index a8065bbe124a..ab7173723095 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -2625,7 +2625,12 @@ static char *get_password(void)
 		return NULL;
 	}
 
-	return pwd;
+	if (pwd == NULL) {
+		free(password);
+		return NULL;
+	}
+
+	return password;
 }
 
 int main(int argc, char *argv[])
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-16 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 15:15 [PATCH v2 ima-evm-utils] evmctl: fix memory leak in get_password Bruno Meneguele
2021-08-16 15:16 ` Bruno Meneguele

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.