[v2,3/5] ima-evm-utils: Fix memory leak in get_password
diff mbox series

Message ID 20190715200553.22403-3-vt@altlinux.org
State New
Headers show
Series
  • [v2,1/5] ima-evm-utils: Fix null dereference from file2bin to memcpy
Related show

Commit Message

Vitaly Chikunov July 15, 2019, 8:05 p.m. UTC
Free allocated password buffer when returning NULL.

Fixes: CID 229894 (partially).
---
 src/evmctl.c | 2 ++
 1 file changed, 2 insertions(+)

Patch
diff mbox series

diff --git a/src/evmctl.c b/src/evmctl.c
index 04dc546..f15056b 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1841,6 +1841,7 @@  static char *get_password(void)
 
 	if (tcsetattr(fileno(stdin), TCSANOW, &tmp_flags) != 0) {
 		perror("tcsetattr");
+		free(password);
 		return NULL;
 	}
 
@@ -1850,6 +1851,7 @@  static char *get_password(void)
 	/* restore terminal */
 	if (tcsetattr(fileno(stdin), TCSANOW, &flags) != 0) {
 		perror("tcsetattr");
+		free(password);
 		return NULL;
 	}