trousers/PATCH-Fix-more-memory-leaks-in-Tspi_Context_Connect.patch
2019-09-30 11:18:49 -04:00

46 lines
1.4 KiB
Diff

From 21d3ca10d52ffadf5abcf57edc52a16d22975c8d Mon Sep 17 00:00:00 2001
From: "Hon Ching(Vicky) Lo" <honclo@linux.vnet.ibm.com>
Date: Wed, 7 Sep 2016 22:11:00 -0400
Subject: [PATCH 23/28] [PATCH] Fix more memory leaks in Tspi_Context_Connect
obj_context_get_machine_name allocated memory for the 'machine_name'.
'machine_name' needs to be freed inside the IF-block of the function,
regardless whether RPC_OpenContext succeeds or fails.
Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
From https://sourceforge.net/p/trousers/trousers/ci/21d3ca10d52ffadf5abcf57edc52a16d22975c8d
---
src/tspi/tspi_context.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/tspi/tspi_context.c b/src/tspi/tspi_context.c
index 93ce3ed..f3e05cf 100644
--- a/src/tspi/tspi_context.c
+++ b/src/tspi/tspi_context.c
@@ -79,8 +79,11 @@ Tspi_Context_Connect(TSS_HCONTEXT tspContext, /* in */
return result;
if ((result = RPC_OpenContext(tspContext, machine_name,
- CONNECTION_TYPE_TCP_PERSISTANT)))
+ CONNECTION_TYPE_TCP_PERSISTANT))) {
+ free(machine_name);
return result;
+ }
+
} else {
if ((machine_name =
Trspi_UNICODE_To_Native((BYTE *)wszDestination, NULL)) == NULL) {
@@ -99,6 +102,8 @@ Tspi_Context_Connect(TSS_HCONTEXT tspContext, /* in */
return result;
}
+ free(machine_name);
+
if ((obj_tpm_add(tspContext, &hTpm)))
return TSPERR(TSS_E_INTERNAL_ERROR);
--
1.8.3.1