From 8884a23b82585a80edb7e1819740b9bff26487c0 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 2 Jun 1994 17:01:03 +0000 Subject: [PATCH] Try doing a reverse address resolution to get the real hostname.. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3679 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/sn2princ.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index 3dc491c1b..3a486462c 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -75,9 +75,30 @@ OLDDECLARG(krb5_principal *,ret_princ) /* copy the hostname into non-volatile storage */ if (type == KRB5_NT_SRV_HST) { + char *addr; + if (!(hp = gethostbyname(hostname))) return KRB5_ERR_BAD_HOSTNAME; remote_host = strdup(hp->h_name); + if (!remote_host) + return ENOMEM; + /* + * Do a reverse resolution to get the full name, just in + * case there's some funny business going on. If there + * isn't an in-addr record, give up. + */ + addr = malloc(hp->h_length); + if (!addr) + return ENOMEM; + memcpy(addr, hp->h_addr, hp->h_length); + hp = gethostbyaddr(addr, hp->h_length, hp->h_addrtype); + free(addr); + if (hp) { + free(remote_host); + remote_host = strdup(hp->h_name); + if (!remote_host) + return ENOMEM; + } } else /* type == KRB5_NT_UNKNOWN */ { remote_host = strdup(hostname); } -- 2.26.2