From de8d9634dbe6b86f60d4e2adbdad5cda5fc8c9aa Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 25 Oct 2010 20:17:54 +0000 Subject: [PATCH] Use safer output parameter handling in krb5_gss_acquire_cred_impersonate_name and its subsidiary helpers. ticket: 6796 target_version: 1.9 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24481 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/gssapi/krb5/s4u_gss_glue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/gssapi/krb5/s4u_gss_glue.c b/src/lib/gssapi/krb5/s4u_gss_glue.c index cecbbb0c0..5e75aede9 100644 --- a/src/lib/gssapi/krb5/s4u_gss_glue.c +++ b/src/lib/gssapi/krb5/s4u_gss_glue.c @@ -50,8 +50,8 @@ kg_impersonate_name(OM_uint32 *minor_status, krb5_error_code code; krb5_creds in_creds, *out_creds = NULL; + *output_cred = NULL; memset(&in_creds, 0, sizeof(in_creds)); - memset(&out_creds, 0, sizeof(out_creds)); in_creds.client = user->princ; in_creds.server = impersonator_cred->name->princ; @@ -161,7 +161,8 @@ krb5_gss_acquire_cred_impersonate_name(OM_uint32 *minor_status, time_rec, context); - *output_cred_handle = (gss_cred_id_t)cred; + if (!GSS_ERROR(major_status)) + *output_cred_handle = (gss_cred_id_t)cred; k5_mutex_unlock(&((krb5_gss_cred_id_t)impersonator_cred_handle)->lock); krb5_free_context(context); @@ -183,6 +184,7 @@ kg_compose_deleg_cred(OM_uint32 *minor_status, krb5_error_code code; krb5_gss_cred_id_t cred = NULL; + *output_cred = NULL; k5_mutex_assert_locked(&impersonator_cred->lock); if (!kg_is_initiator_cred(impersonator_cred) || -- 2.26.2