[v1,2/5] ima-evm-utils: Fix memory leak in init_public_keys
diff mbox series

Message ID 20190707234837.4866-3-vt@altlinux.org
State New
Headers show
Series
  • ima-evm-utils: Assorted fixes and improvements
Related show

Commit Message

Vitaly Chikunov July 7, 2019, 11:48 p.m. UTC
strdup'ed string should be freed. Found with ASan.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---
 src/libimaevm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/libimaevm.c b/src/libimaevm.c
index fe1962b..b556276 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -421,11 +421,12 @@  static EVP_PKEY *find_keyid(uint32_t keyid)
 void init_public_keys(const char *keyfiles)
 {
 	struct public_key_entry *entry;
-	char *tmp_keyfiles;
+	char *tmp_keyfiles, *keyfiles_free;
 	char *keyfile;
 	int i = 1;
 
 	tmp_keyfiles = strdup(keyfiles);
+	keyfiles_free = tmp_keyfiles;
 
 	while ((keyfile = strsep(&tmp_keyfiles, ", \t")) != NULL) {
 		if (!keyfile)
@@ -452,6 +453,7 @@  void init_public_keys(const char *keyfiles)
 		entry->next = public_keys;
 		public_keys = entry;
 	}
+	free(keyfiles_free);
 }
 
 /*