From 78c261f689e77d954ba295f8ef172ef4219fc364 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Tue, 3 Jan 2023 20:48:28 -0600 Subject: [PATCH] gsskrb5: Add missing error check in cred import --- lib/gssapi/krb5/creds.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/gssapi/krb5/creds.c b/lib/gssapi/krb5/creds.c index efb0a23ad..036d9fa07 100644 --- a/lib/gssapi/krb5/creds.c +++ b/lib/gssapi/krb5/creds.c @@ -263,10 +263,15 @@ _gsskrb5_import_cred(OM_uint32 * minor_status, *minor_status = ENOMEM; return GSS_S_FAILURE; } + *minor_status = krb5_cc_get_principal(context, id, &handle->principal); + if (*minor_status) { + free(handle); + krb5_cc_close(context, id); + return GSS_S_FAILURE; + } handle->usage = GSS_C_INITIATE; handle->destination_realm = NULL; - krb5_cc_get_principal(context, id, &handle->principal); handle->ccache = id; handle->cred_flags = flags;