From 44bac2bf7b8537a7cd414a883b5c89042c6ad179 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Dec 2004 22:07:04 +0000 Subject: r4334: Fix for bugid #2186 - from Buck Huppmann to prevent uninitialized creds being freed. Jeremy. (This used to be commit c3f9c81a8fcb26f7110f75b3096d5d1eb30aac13) --- source3/lib/util_str.c | 8 ++++++++ source3/libads/kerberos.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index c6b6570f5c..6ebada94d7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1527,6 +1527,9 @@ int fstr_sprintf(fstring s, const char *fmt, ...) /** Some platforms don't have strndup. **/ +#if defined(PARANOID_MALLOC_CHECKER) +#undef strndup +#endif char *strndup(const char *s, size_t n) { @@ -1541,6 +1544,11 @@ int fstr_sprintf(fstring s, const char *fmt, ...) return ret; } + +#if defined(PARANOID_MALLOC_CHECKER) +#define strndup(s,n) __ERROR_DONT_USE_STRNDUP_DIRECTLY +#endif + #endif #if !defined(HAVE_STRNLEN) || defined(BROKEN_STRNLEN) diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c index a38f3c35b1..b08e28e0ba 100644 --- a/source3/libads/kerberos.c +++ b/source3/libads/kerberos.c @@ -320,6 +320,8 @@ static krb5_error_code get_service_ticket(krb5_context ctx, krb5_auth_context auth_context = NULL; krb5_error_code err = 0; + ZERO_STRUCT(creds); + asprintf(&machine_account, "%s$@%s", global_myname(), lp_realm()); if (machine_account == NULL) { goto out; @@ -340,7 +342,6 @@ static krb5_error_code get_service_ticket(krb5_context ctx, ticket to ourselves. */ /* Set up the enctype and client and server principal fields for krb5_get_credentials. */ - memset(&creds, '\0', sizeof(creds)); kerberos_set_creds_enctype(&creds, enctype); if ((err = krb5_cc_get_principal(ctx, ccache, &creds.client))) { -- cgit