[PATCH v1 2/5] ima-evm-utils: Fix memory leak in init_public_keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



strdup'ed string should be freed. Found with ASan.

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

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);
 }
 
 /*
-- 
2.11.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux