Fix potential leaks in delete_context
authorSimo Sorce <simo@redhat.com>
Mon, 16 Dec 2013 01:09:56 +0000 (20:09 -0500)
committerSimo Sorce <simo@redhat.com>
Mon, 16 Dec 2013 01:44:09 +0000 (20:44 -0500)
Free RC4 state if any
Free workstations tring if any

Also make sure to safely zero the struct before freeing to avoid leaking any
key material.

src/gss_sec_ctx.c

index 4ed1b1929f1fa71c16754ff951db36e922196ec7..9203939f5cd42fb5a7c7a85d7a955ae99dfa4340 100644 (file)
@@ -627,6 +627,8 @@ uint32_t gssntlm_delete_sec_context(uint32_t *minor_status,
 
     ctx = (struct gssntlm_ctx *)*context_handle;
 
+    safefree(ctx->workstation);
+
     ret = ntlm_free_ctx(&ctx->ntlm);
 
     safefree(ctx->nego_msg.data);
@@ -639,6 +641,10 @@ uint32_t gssntlm_delete_sec_context(uint32_t *minor_status,
     gssntlm_int_release_name(&ctx->source_name);
     gssntlm_int_release_name(&ctx->target_name);
 
+    RC4_FREE(&ctx->send.seal_handle);
+    RC4_FREE(&ctx->recv.seal_handle);
+
+    safezero(*context_handle, sizeof(struct gssntlm_ctx));
     safefree(*context_handle);
 
     if (ret) {