From 8cb7facb419fdbe46ad337b8b62d359a7a87c6a4 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Tue, 18 Apr 1995 21:49:44 +0000 Subject: [PATCH] an_to_ln.c (dbm_an_to_ln): Don't compile dbm_an_to_ln() if USE_DBM_LNAME isn't defined. hst_realm.c (krb5_get_host_realm): Eliminate memory leak in the unlikely case that gethostname fails. If the krb.realms file isn't available, use the default realm of the host. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5367 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 13 +++++++++++++ src/lib/krb5/os/an_to_ln.c | 4 ++++ src/lib/krb5/os/hst_realm.c | 10 +++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index f647257c0..c4e2df84e 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,16 @@ +Fri Apr 14 22:15:00 1995 Theodore Y. Ts'o + + * an_to_ln.c (dbm_an_to_ln): Don't compile dbm_an_to_ln() if + USE_DBM_LNAME isn't defined. + +Fri Apr 14 15:15:48 1995 + + * hst_realm.c (krb5_get_host_realm): Eliminate memory leak in the + unlikely case that gethostname fails. + + If the krb.realms file isn't available, use the default + realm of the host. + Thu Apr 13 15:49:16 1995 Keith Vetter (keithv@fusion.com) * *.[ch]: removed unneeded INTERFACE from non-api functions. diff --git a/src/lib/krb5/os/an_to_ln.c b/src/lib/krb5/os/an_to_ln.c index cb11cfdd1..d6c429ddf 100644 --- a/src/lib/krb5/os/an_to_ln.c +++ b/src/lib/krb5/os/an_to_ln.c @@ -59,13 +59,16 @@ krb5_aname_to_localname(context, aname, lnsize, lname) { struct stat statbuf; +#ifdef USE_DBM_LNAME if (!stat(krb5_lname_file,&statbuf)) return dbm_an_to_ln(context, aname, lnsize, lname); +#endif if (krb5_lname_username_fallback) return username_an_to_ln(context, aname, lnsize, lname); return KRB5_LNAME_CANTOPEN; } +#ifdef USE_DBM_LNAME /* * Implementation: This version uses a DBM database, indexed by aname, * to generate a lname. @@ -116,6 +119,7 @@ dbm_an_to_ln(context, aname, lnsize, lname) (void) dbm_close(db); return retval; } +#endif /* USE_DBM_LNAME */ #endif /* _MSDOS */ /* diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index 950e2d04b..a3193cbbd 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -148,8 +148,6 @@ krb5_get_host_realm(context, host, realmsp) char scanstring[7+2*16]; /* 7 chars + 16 for each decimal conversion */ - if (!(retrealms = (char **)calloc(2, sizeof(*retrealms)))) - return ENOMEM; if (!host) { if (gethostname(local_host, sizeof(local_host)-1) == -1) return errno; @@ -158,6 +156,9 @@ krb5_get_host_realm(context, host, realmsp) } domain = strchr(host, '.'); + if (!(retrealms = (char **)calloc(2, sizeof(*retrealms)))) + return ENOMEM; + /* prepare default */ if (domain) { char *cp; @@ -180,9 +181,8 @@ krb5_get_host_realm(context, host, realmsp) krb5_find_config_files(); if ((trans_file = fopen(krb5_trans_file, "r")) == (FILE *) 0) { - krb5_xfree(retrealms[0]); - krb5_xfree(retrealms); - return KRB5_TRANS_CANTOPEN; + *realmsp = retrealms; + return 0; } (void) sprintf(scanstring, "%%%ds %%%ds", sizeof(trans_host)-1,sizeof(trans_realm)-1); -- 2.26.2