From b5b75b2d8abcbe3cf85a616d56e747ff0f6185af Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 17 Jun 2014 08:51:41 -0600 Subject: [PATCH] Don't call gss_krb5_ccache_name() with a NULL pointer when restoring the old credential cache file name. This can happen if there was no old name returned by gss_krb5_ccache_name(). Fixes a crash on kerberized LDAP on some platforms. --- plugins/sudoers/ldap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index 3fbbbdd23..5890e4b96 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -2423,19 +2423,20 @@ sudo_ldap_bind_s(LDAP *ld) old_ccname ? old_ccname : "(none)", new_ccname); } else { sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO, - "gss_krb5_ccache_name() failed: %d", rc); + "sudo_set_krb5_ccache_name() failed: %d", rc); } } rc = ldap_sasl_interactive_bind_s(ld, ldap_conf.binddn, "GSSAPI", NULL, NULL, LDAP_SASL_QUIET, sudo_ldap_sasl_interact, auth_id); if (new_ccname != NULL) { - rc = sudo_set_krb5_ccache_name(old_ccname, NULL); + rc = sudo_set_krb5_ccache_name(old_ccname ? old_ccname : "", NULL); if (rc == 0) { sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO, - "restore ccache name %s -> %s", new_ccname, old_ccname); + "restore ccache name %s -> %s", new_ccname, + old_ccname ? old_ccname : "(none)"); } else { sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO, - "gss_krb5_ccache_name() failed: %d", rc); + "sudo_set_krb5_ccache_name() failed: %d", rc); } /* Remove temporary copy of user's credential cache. */ if (tmp_ccname != NULL)