From fa6ceead4e5622dee740781ddfa9e0e3a7ce053c Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 21 Dec 1995 23:19:13 +0000 Subject: [PATCH] * Makefile.in (t_an_to_ln): Use $(LD) instead of $(CC) to link final executables, so that we can more easily use purify. * hst_realm.c (krb5_get_host_realm): Eliminate memory leak; realm was already being allocated by the profile library; no reason to reallocate it again. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7241 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 9 +++++++ src/lib/krb5/os/Makefile.in | 4 +-- src/lib/krb5/os/hst_realm.c | 52 +++++++++++++++---------------------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index c8132de6b..8c3d5edcb 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,12 @@ +Thu Dec 21 17:51:58 1995 Theodore Y. Ts'o + + * Makefile.in (t_an_to_ln): Use $(LD) instead of $(CC) to link + final executables, so that we can more easily use purify. + + * hst_realm.c (krb5_get_host_realm): Eliminate memory leak; realm + was already being allocated by the profile library; no + reason to reallocate it again. + Wed Nov 15 10:53:16 1995 * promptusr.c: New function for doing generic tty input and output. diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in index 8d25ddefe..9e1d67485 100644 --- a/src/lib/krb5/os/Makefile.in +++ b/src/lib/krb5/os/Makefile.in @@ -108,10 +108,10 @@ T_AN_TO_LN_OBJS = t_an_to_ln.o an_to_ln.o $(TOPLIBD)/libkrb5.a \ $(TOPLIBD)/libcrypto.a $(COMERRLIB) t_std_conf: $(T_STD_CONF_OBJS) - $(CC) -o t_std_conf $(T_STD_CONF_OBJS) $(LIBS) + $(LD) -o t_std_conf $(T_STD_CONF_OBJS) $(LIBS) t_an_to_ln: $(T_AN_TO_LN_OBJS) - $(CC) -o t_an_to_ln $(T_AN_TO_LN_OBJS) $(LIBS) + $(LD) -o t_an_to_ln $(T_AN_TO_LN_OBJS) $(LIBS) check-unix:: $(TEST_PROGS) KRB5_CONFIG=$(srcdir)/td_krb5.conf ; export KRB5_CONFIG ;\ diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index 2062928cc..b93ed379e 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -84,7 +84,7 @@ krb5_get_host_realm(context, host, realmsp) char ***realmsp; { char **retrealms; - char *domain, *default_realm, *realm, *cp; + char *default_realm, *realm, *cp; krb5_error_code retval; int l; char local_host[MAXHOSTNAMELEN+1]; @@ -139,35 +139,25 @@ krb5_get_host_realm(context, host, realmsp) } } - if (realm != (char *)NULL) - { - /* We found an exact match */ - if (!(cp = (char *)malloc(strlen(realm)+1))) - return ENOMEM; - strcpy(cp, realm); - realm = cp; - } - else if (default_realm != (char *)NULL) - { - /* We are defaulting to the realm of the host */ - if (!(cp = (char *)malloc(strlen(default_realm)+1))) - return ENOMEM; - strcpy(cp, default_realm); - realm = cp; - - /* Assume the realm name is upper case */ - for (cp = realm; *cp; cp++) - if (islower(*cp)) - *cp = toupper(*cp); - cp = realm; - } - else - { - /* We are defaulting to the local realm */ - retval = krb5_get_default_realm(context, &cp); - if (retval) { - return retval; - } + if (realm == (char *)NULL) { + if (default_realm != (char *)NULL) { + /* We are defaulting to the realm of the host */ + if (!(cp = (char *)malloc(strlen(default_realm)+1))) + return ENOMEM; + strcpy(cp, default_realm); + realm = cp; + + /* Assume the realm name is upper case */ + for (cp = realm; *cp; cp++) + if (islower(*cp)) + *cp = toupper(*cp); + } else { + /* We are defaulting to the local realm */ + retval = krb5_get_default_realm(context, &realm); + if (retval) { + return retval; + } + } } if (!(retrealms = (char **)calloc(2, sizeof(*retrealms)))) { if (realm != (char *)NULL) @@ -175,7 +165,7 @@ krb5_get_host_realm(context, host, realmsp) return ENOMEM; } - retrealms[0] = cp; + retrealms[0] = realm; retrealms[1] = 0; *realmsp = retrealms; -- 2.26.2