diff options
author | Tom Yu <tlyu@mit.edu> | 1996-11-13 07:54:27 +0000 |
---|---|---|
committer | Tom Yu <tlyu@mit.edu> | 1996-11-13 07:54:27 +0000 |
commit | 6742799bb6a8a7e08fd90687636805e34faffc02 (patch) | |
tree | fd485808191e4eb0357b6d9cabe2402629e45591 | |
parent | 5de80315012cb77807cb8e4c86602cddf2a0f86f (diff) | |
download | krb5-6742799bb6a8a7e08fd90687636805e34faffc02.zip krb5-6742799bb6a8a7e08fd90687636805e34faffc02.tar.gz krb5-6742799bb6a8a7e08fd90687636805e34faffc02.tar.bz2 |
* 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
-rw-r--r-- | src/lib/krb5/os/ChangeLog | 5 | ||||
-rw-r--r-- | 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 1016bd6..124935e 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 <tlyu@mit.edu> + + * 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 <tlyu@mit.edu> * 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 83bb992..ef5391a 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)) |