From def9f9a0706a18cb1bc0f44b39d55e4e81c788ff Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Tue, 24 Aug 2010 07:08:36 +0000 Subject: stop using MAXHOSTNAMELEN in a variety of places. Also nuke-trailing-whitespace. --- lib/ZExpnRlm.c | 2 +- lib/ZInit.c | 40 ++++++++++++++++++---------------------- lib/ZLocations.c | 16 ++++++++-------- 3 files changed, 27 insertions(+), 31 deletions(-) (limited to 'lib') diff --git a/lib/ZExpnRlm.c b/lib/ZExpnRlm.c index 1b752a9..54c2fdb 100644 --- a/lib/ZExpnRlm.c +++ b/lib/ZExpnRlm.c @@ -48,7 +48,7 @@ char *realm; #else int retval; FILE *rlm_file; - char krb_host[MAXHOSTNAMELEN+1]; + char krb_host[NS_MAXDNAME + 1]; static char krb_realm[REALM_SZ+1]; char linebuf[BUFSIZ]; char scratch[64]; diff --git a/lib/ZInit.c b/lib/ZInit.c index f6ec6de..8339cf3 100644 --- a/lib/ZInit.c +++ b/lib/ZInit.c @@ -7,7 +7,7 @@ * * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file - * "mit-copyright.h". + * "mit-copyright.h". */ #ifndef lint @@ -51,7 +51,7 @@ ZInitialize(void) { struct servent *hmserv; struct hostent *hostent; - char addr[4], hostname[MAXHOSTNAMELEN]; + char addr[4], hostname[NS_MAXDNAME]; struct in_addr servaddr; struct sockaddr_in sin; unsigned int s, sinsize = sizeof(sin); @@ -67,8 +67,8 @@ ZInitialize(void) #endif #endif - /* On OS X you don't need to initialize the Kerberos error tables - as long as you link with -framework Kerberos */ + /* On OS X you don't need to initialize the Kerberos error tables + as long as you link with -framework Kerberos */ #if !(defined(__APPLE__) && defined(__MACH__)) #ifdef HAVE_KRB4 initialize_krb_error_table(); @@ -78,12 +78,12 @@ ZInitialize(void) #endif #endif -#if defined(__APPLE__) && defined(__MACH__) - add_error_table(&et_zeph_error_table); -#else +#if defined(__APPLE__) && defined(__MACH__) + add_error_table(&et_zeph_error_table); +#else initialize_zeph_error_table(); #endif - + (void) memset((char *)&__HM_addr, 0, sizeof(__HM_addr)); __HM_addr.sin_family = AF_INET; @@ -104,7 +104,7 @@ ZInitialize(void) /* Initialize the input queue */ __Q_Tail = NULL; __Q_Head = NULL; - + #ifdef HAVE_KRB5 if ((code = krb5_init_context(&Z_krb5_ctx))) return(code); @@ -239,10 +239,6 @@ struct sockaddr_in ZGetDestAddr (void) { #if defined(HAVE_KRB5) && defined(KRB5_REFERRAL_REALM) #include #include -#include -#ifdef HAVE_ARPA_NAMESER_COMPAT_H -#include -#endif #include static int txt_lookup(char *qname, char **result) { @@ -250,7 +246,7 @@ static int txt_lookup(char *qname, char **result) { void *buf = NULL; HEADER *hdr; unsigned char *p; - char dname[MAXDNAME]; + char dname[NS_MAXDNAME]; int queries, answers, stored; ret = res_init(); @@ -261,7 +257,7 @@ static int txt_lookup(char *qname, char **result) { do { buflen = buflen ? buflen * 2 : 2048; buf = (buf == NULL) ? malloc(buflen) : realloc(buf, buflen); - + ret = res_search(qname, C_IN, T_TXT, buf, buflen); } while (ret > buflen); @@ -292,7 +288,7 @@ static int txt_lookup(char *qname, char **result) { stored = 0; while (answers--) { int class, type; - + ret = dn_expand(buf, buf + buflen, p, dname, sizeof dname); if (ret < 0 || ret > left) return -1; @@ -324,7 +320,7 @@ static int txt_lookup(char *qname, char **result) { p += ret; } return -1; -} +} static int z_get_host_realm_replacement(char *inhost, char ***krealms) { @@ -335,7 +331,7 @@ z_get_host_realm_replacement(char *inhost, char ***krealms) { char *qname; profile_t prof; int ret; - + host = strdup(inhost); for (p = host; *p; p++) @@ -397,9 +393,9 @@ z_get_host_realm_replacement(char *inhost, char ***krealms) { sprintf(qname, "_kerberos.%s.", p); ret = txt_lookup(qname, &realm); free(qname); - + p = strchr(p,'.'); - if (p) + if (p) p++; } while (ret && p && p[0]); } @@ -411,7 +407,7 @@ z_get_host_realm_replacement(char *inhost, char ***krealms) { free(host); return errno; } - + for (p = realm; *p; p++) if (islower(*p)) *p = toupper(*p); @@ -423,7 +419,7 @@ z_get_host_realm_replacement(char *inhost, char ***krealms) { } } } - + free(host); if ((*krealms = calloc(2, sizeof(*krealms))) == NULL) { diff --git a/lib/ZLocations.c b/lib/ZLocations.c index db6daa6..b0c197c 100644 --- a/lib/ZLocations.c +++ b/lib/ZLocations.c @@ -8,7 +8,7 @@ * * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file - * "mit-copyright.h". + * "mit-copyright.h". */ #ifndef lint @@ -20,7 +20,7 @@ static const char rcsid_ZLocations_c[] = #include -static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN]; +static char host[NS_MAXDNAME], mytty[MAXPATHLEN]; static int location_info_set = 0; Code_t @@ -33,7 +33,7 @@ ZInitLocationInfo(char *hostname, if (hostname) { strcpy(host, hostname); } else { - if (gethostname(host, MAXHOSTNAMELEN) < 0) + if (gethostname(host, sizeof(host)) < 0) return (errno); hent = gethostbyname(host); if (hent) { @@ -59,14 +59,14 @@ ZInitLocationInfo(char *hostname, Code_t ZSetLocation(char *exposure) { - return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, + return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, "$sender logged in to $1 on $3 at $2")); } Code_t ZUnsetLocation(void) { - return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, + return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, "$sender logged out of $1 on $3 at $2")); } @@ -158,8 +158,8 @@ Z_SendLocation(char *class, } ZFreeNotice(&retnotice); return (ZERR_SERVNAK); - } - + } + if (retnotice.z_kind != SERVACK) { ZFreeNotice(&retnotice); return (ZERR_INTERNAL); @@ -177,6 +177,6 @@ Z_SendLocation(char *class, } ZFreeNotice(&retnotice); - + return (ZERR_NONE); } -- cgit v1.2.3