svn rev #22636: trunk/src/lib/gssapi/spnego/

ghudson@MIT.EDU ghudson at MIT.EDU
Thu Aug 27 09:40:51 EDT 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=22636
Commit By: ghudson
Log Message:
ticket: 6551
subject: Memory leak in spnego accept_sec_context error path
tags: pullup
target_version: 1.7

If the underlying mechanism's accept_sec_context returns an error, the
spnego accept_sec_context was leaving allocated data in
*context_handle, which is incorrect for the first call according to
RFC 2744.

Fix this by mirroring some code from the spnego init_sec_context,
which always cleans up the half-constructed context in case of error.
This is allowed (though not encouraged) by RFC 2744 for second and
subsequent calls; since we were already doing it in init_sec_context,
it seems simpler to do that than keep track of whether this is a first
call or not.



Changed Files:
U   trunk/src/lib/gssapi/spnego/spnego_mech.c
Modified: trunk/src/lib/gssapi/spnego/spnego_mech.c
===================================================================
--- trunk/src/lib/gssapi/spnego/spnego_mech.c	2009-08-27 12:55:47 UTC (rev 22635)
+++ trunk/src/lib/gssapi/spnego/spnego_mech.c	2009-08-27 13:40:50 UTC (rev 22636)
@@ -1681,6 +1681,13 @@
 			*src_name = sc->internal_name;
 		}
 		release_spnego_ctx(&sc);
+	} else if (ret != GSS_S_CONTINUE_NEEDED) {
+		if (sc != NULL) {
+			gss_delete_sec_context(&tmpmin, &sc->ctx_handle,
+					       GSS_C_NO_BUFFER);
+			release_spnego_ctx(&sc);
+		}
+		*context_handle = GSS_C_NO_CONTEXT;
 	}
 	gss_release_buffer(&tmpmin, &mechtok_out);
 	if (mechtok_in != GSS_C_NO_BUFFER) {




More information about the cvs-krb5 mailing list