krb5 commit: Fix memory leak in SPNEGO gss_init_sec_context()

Greg Hudson ghudson at mit.edu
Mon Jan 11 11:51:39 EST 2016


https://github.com/krb5/krb5/commit/159dbbd5ff14fdc2fa71fb3a8804eb401c914399
commit 159dbbd5ff14fdc2fa71fb3a8804eb401c914399
Author: Greg Hudson <ghudson at mit.edu>
Date:   Wed Nov 25 14:43:35 2015 -0500

    Fix memory leak in SPNEGO gss_init_sec_context()
    
    After the initial call to spnego_gss_init_sec_context(), the context
    handle can leak if init_ctx_cont() returns an error, because the
    cleanup handler assumes that spnego_ctx contains the value of
    *context_handle.  Fix this leak by setting spnego_ctx before the if
    block which contains that call.  Reported by Adam Bernstein.
    
    ticket: 8281 (new)
    target_version: 1.14.1
    tags: pullup

 src/lib/gssapi/spnego/spnego_mech.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/lib/gssapi/spnego/spnego_mech.c b/src/lib/gssapi/spnego/spnego_mech.c
index 5833994..c7de261 100644
--- a/src/lib/gssapi/spnego/spnego_mech.c
+++ b/src/lib/gssapi/spnego/spnego_mech.c
@@ -1032,7 +1032,8 @@ spnego_gss_init_sec_context(
 
 	/* Step 1: perform mechanism negotiation. */
 	spcred = (spnego_gss_cred_id_t)claimant_cred_handle;
-	if (*context_handle == GSS_C_NO_CONTEXT) {
+	spnego_ctx = (spnego_gss_ctx_id_t)*context_handle;
+	if (spnego_ctx == NULL) {
 		ret = init_ctx_new(minor_status, spcred,
 				   context_handle, &send_token);
 		if (ret != GSS_S_CONTINUE_NEEDED) {


More information about the cvs-krb5 mailing list