From 173dda6bf4db2faf29a1845ce2b1028105511dab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 30 Oct 2004 11:37:17 +0000 Subject: r3391: fixed some memory leaks in the schannel code (This used to be commit eb3366d3667ddddf7ab5eae5d1fbc5de86c41072) --- source4/libcli/auth/schannel.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'source4/libcli/auth/schannel.c') diff --git a/source4/libcli/auth/schannel.c b/source4/libcli/auth/schannel.c index a99822534b..2f20a3e906 100644 --- a/source4/libcli/auth/schannel.c +++ b/source4/libcli/auth/schannel.c @@ -23,7 +23,6 @@ #include "includes.h" struct schannel_state { - TALLOC_CTX *mem_ctx; uint8_t session_key[16]; uint32_t seq_num; BOOL initiator; @@ -219,7 +218,7 @@ NTSTATUS schannel_seal_packet(struct schannel_state *state, netsec_deal_with_seq_num(state, digest_final, seq_num); - (*sig) = data_blob_talloc(state->mem_ctx, NULL, 32); + (*sig) = data_blob_talloc(mem_ctx, NULL, 32); memcpy(sig->data, netsec_sig, 8); memcpy(sig->data+8, seq_num, 8); @@ -256,7 +255,7 @@ NTSTATUS schannel_sign_packet(struct schannel_state *state, netsec_deal_with_seq_num(state, digest_final, seq_num); - (*sig) = data_blob_talloc(state->mem_ctx, NULL, 32); + (*sig) = data_blob_talloc(mem_ctx, NULL, 32); memcpy(sig->data, netsec_sig, 8); memcpy(sig->data+8, seq_num, 8); @@ -277,7 +276,7 @@ NTSTATUS schannel_sign_packet(struct schannel_state *state, void schannel_end(struct schannel_state **state) { if (*state) { - talloc_destroy((*state)->mem_ctx); + talloc_free(*state); (*state) = NULL; } } @@ -289,20 +288,11 @@ NTSTATUS schannel_start(struct schannel_state **state, const uint8_t session_key[16], BOOL initiator) { - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("schannel_state"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - (*state) = talloc_p(mem_ctx, struct schannel_state); + (*state) = talloc_p(NULL, struct schannel_state); if (!(*state)) { - talloc_destroy(mem_ctx); return NT_STATUS_NO_MEMORY; } - (*state)->mem_ctx = mem_ctx; memcpy((*state)->session_key, session_key, 16); (*state)->initiator = initiator; (*state)->seq_num = 0; -- cgit