Skip Menu |
 

Subject: memory leak on SPNEGO error path
Date: Wed, 9 Feb 2011 15:48:55 -0500
From: "Arlene Berry" <aberry@likewise.com>
To: <krb5-bugs@mit.edu>
Download (untitled) / with headers
text/plain 1.4KiB
We ran into this awhile ago and I think the issue was that a failure on
a non-initial call to gss_init_sec_context or gss_accept_sec_context
results in the SPNEGO context being freed. The caller then calls
gss_delete_sec_context on the union context which calls down into SPNEGO
which calls gss_delete_sec_context on the NULL context which reports an
error. The error is passed up to the mechglue layer which returns it
and doesn't free the union context.

Index: src/lib/gssapi/spnego/spnego_mech.c
===================================================================
--- src/lib/gssapi/spnego/spnego_mech.c (revision 24618)
+++ src/lib/gssapi/spnego/spnego_mech.c (working copy)
@@ -2080,16 +2080,18 @@
/*
* If this is still an SPNEGO mech, release it locally.
*/
- if (*ctx != NULL &&
- (*ctx)->magic_num == SPNEGO_MAGIC_ID) {
- (void) gss_delete_sec_context(minor_status,
- &(*ctx)->ctx_handle,
- output_token);
- (void) release_spnego_ctx(ctx);
- } else {
- ret = gss_delete_sec_context(minor_status,
- context_handle,
- output_token);
+ if (*ctx != NULL)
+ {
+ if ((*ctx)->magic_num == SPNEGO_MAGIC_ID) {
+ (void) gss_delete_sec_context(minor_status,
+ &(*ctx)->ctx_handle,
+ output_token);
+ (void) release_spnego_ctx(ctx);
+ } else {
+ ret = gss_delete_sec_context(minor_status,
+ context_handle,
+ output_token);
+ }
}

return (ret);
From: ghudson@mit.edu
Subject: SVN Commit

SPNEGO's accept_sec_context and init_sec_context produce a null context
on error, so it needs to silently succeed when deleting a null context.
It was instead passing the null context along to the mechglue which
would produce an error, causing a leak of the mechglue's union context
wrapper. Reported by aberry@likewise.com.


https://github.com/krb5/krb5/commit/d5c4a1fe9994542a4f1d1faab7235e2ad5aa4f92
Commit By: ghudson
Revision: 24692
Changed Files:
U trunk/src/lib/gssapi/spnego/spnego_mech.c