From 6742799bb6a8a7e08fd90687636805e34faffc02 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 13 Nov 1996 07:54:27 +0000 Subject: [PATCH] * ktdefname.c (krb5_kt_default_name): Fix a few memory-leak type problems in previous changes. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9402 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 5 +++++ src/lib/krb5/os/ktdefname.c | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 1016bd6aa..124935ea1 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,8 @@ +Wed Nov 13 02:53:31 1996 Tom Yu + + * ktdefname.c (krb5_kt_default_name): Fix a few memory-leak type + problems in previous changes. + Tue Nov 12 22:07:55 1996 Tom Yu * osconfig.c: Remove krb5_defkeyname to catch other things that diff --git a/src/lib/krb5/os/ktdefname.c b/src/lib/krb5/os/ktdefname.c index 83bb99278..ef5391ab4 100644 --- a/src/lib/krb5/os/ktdefname.c +++ b/src/lib/krb5/os/ktdefname.c @@ -41,11 +41,14 @@ krb5_kt_default_name(context, name, namesize) if (context->kt_default_name == NULL) { if ((context->profile_secure == FALSE) && (cp = getenv("KRB5_KTNAME"))) { + if ((context->kt_default_name = malloc(strlen(cp) + 1)) == NULL) + return ENOMEM; + strcpy(context->kt_default_name, cp); } else if (((code = profile_get_string(context->profile, "libdefaults", "default_keytab_name", NULL, NULL, &cp)) == 0) && cp){ - ; + context->kt_default_name = cp; } else { #if defined (_MSDOS) || defined(_WIN32) { @@ -58,17 +61,15 @@ krb5_kt_default_name(context, name, namesize) == NULL) return ENOMEM; sprintf(cp, DEFAULT_KEYTAB_NAME, defname); + context->kt_default_name = cp; } #else if ((cp = malloc(strlen(DEFAULT_KEYTAB_NAME) + 1)) == NULL) return ENOMEM; strcpy(cp, DEFAULT_KEYTAB_NAME); + context->kt_default_name = cp; #endif } - /* cache the result... */ - if ((context->kt_default_name = malloc(strlen(cp) + 1)) == NULL) - return ENOMEM; - strcpy(context->kt_default_name, cp); } strncpy(name, context->kt_default_name, namesize); if ((size_t) namesize < strlen(context->kt_default_name)) -- 2.26.2