From: John Kohl Date: Thu, 21 Mar 1991 13:44:49 +0000 (+0000) Subject: use strdup for hostname as well X-Git-Tag: krb5-1.0-alpha4~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8704f329e2f8422da77a15664f18784c9a595829;p=krb5.git use strdup for hostname as well allow non-canonicalization git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1938 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index cd9dcc7f1..71f4d4f41 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -13,7 +13,7 @@ */ #if !defined(lint) && !defined(SABER) -static char rcsid_modulsn2princ_c[] = +static char rcsid_sn2princ_c[] = "$Id$"; #endif /* !lint & !SABER */ @@ -36,10 +36,14 @@ register char *s; #endif krb5_error_code -krb5_sname_to_principal(hostname, sname, ret_princ) -const char *hostname; -const char *sname; -krb5_principal *ret_princ; +krb5_sname_to_principal(DECLARG(const char *,hostname), + DECLARG(const char *,sname), + DECLARG(krb5_boolean,canonicalize), + DECLARG(krb5_principal *,ret_princ)) +OLDDECLARG(const char *,hostname) +OLDDECLARG(const char *,sname) +OLDDECLARG(krb5_boolean,canonicalize) +OLDDECLARG(krb5_principal *,ret_princ) { krb5_principal lprinc; struct hostent *hp; @@ -47,14 +51,17 @@ krb5_principal *ret_princ; krb5_error_code retval; register char **cpp, *cp; - if (!(hp = gethostbyname(hostname))) - return KRB5_ERR_BAD_HOSTNAME; - /* copy the hostname into non-volatile storage */ - remote_host = malloc(strlen(hp->h_name) + 1); + + if (canonicalize) { + if (!(hp = gethostbyname(hostname))) + return KRB5_ERR_BAD_HOSTNAME; + remote_host = strdup(hp->h_name); + } else { + remote_host = strdup(hostname); + } if (!remote_host) return ENOMEM; - (void) strcpy(remote_host, hp->h_name); for (cp = remote_host; *cp; cp++) if (isupper(*cp))