From e47f9415b77cf9f7290379a531a4d371b6f3aeda Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 11 May 2024 02:38:21 +0200 Subject: [PATCH] s3:libads: don't allow ads_kdestroy(NULL) anymore This should not happen, if we ever need that behaviour we should add an ads_kdestroy_default() helper. Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- source3/libads/kerberos.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c index f76c5665205..241b2d92718 100644 --- a/source3/libads/kerberos.c +++ b/source3/libads/kerberos.c @@ -284,23 +284,25 @@ int ads_kdestroy(const char *cc_name) return code; } - if (!cc_name) { - if ((code = krb5_cc_default(ctx, &cc))) { - krb5_free_context(ctx); - return code; - } - } else { - if ((code = krb5_cc_resolve(ctx, cc_name, &cc))) { - DEBUG(3, ("ads_kdestroy: krb5_cc_resolve failed: %s\n", - error_message(code))); - krb5_free_context(ctx); - return code; - } + /* + * This should not happen, if + * we need that behaviour we + * should add an ads_kdestroy_default() + */ + SMB_ASSERT(cc_name != NULL); + + code = krb5_cc_resolve(ctx, cc_name, &cc); + if (code != 0) { + DBG_NOTICE("krb5_cc_resolve(%s) failed: %s\n", + cc_name, error_message(code)); + krb5_free_context(ctx); + return code; } - if ((code = krb5_cc_destroy (ctx, cc))) { - DEBUG(3, ("ads_kdestroy: krb5_cc_destroy failed: %s\n", - error_message(code))); + code = krb5_cc_destroy(ctx, cc); + if (code != 0) { + DBG_ERR("krb5_cc_destroy(%s) failed: %s\n", + cc_name, error_message(code)); } krb5_free_context (ctx);