If gss_acquire_cred_impersonate_name is called using an
impersonator_cred_handle acquired with GSS_C_ACCEPT, we could
dereference null fields of the cred handle and crash. Fix this by
checking the impersonator_cred_handle usage and returning
GSS_S_NO_CRED if it isn't what we expect, just as we do in
init_sec_context.
Based on a patch from Solly Ross <sross@redhat.com>.
ticket: 8017 (new)
target_version: 1.13
tags: pullup
{
OM_uint32 major_status;
krb5_error_code code;
+ krb5_gss_cred_id_t imp_cred = (krb5_gss_cred_id_t)impersonator_cred_handle;
krb5_gss_cred_id_t cred;
krb5_context context;
return GSS_S_FAILURE;
}
+ if (imp_cred->usage != GSS_C_INITIATE && imp_cred->usage != GSS_C_BOTH) {
+ *minor_status = 0;
+ return GSS_S_NO_CRED;
+ }
+
*output_cred_handle = GSS_C_NO_CREDENTIAL;
if (time_rec != NULL)
*time_rec = 0;
}
major_status = kg_impersonate_name(minor_status,
- (krb5_gss_cred_id_t)impersonator_cred_handle,
+ imp_cred,
(krb5_gss_name_t)desired_name,
time_req,
&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);
+ k5_mutex_unlock(&imp_cred->lock);
krb5_free_context(context);
return major_status;