(getnameinfo_verified): handle the case of forward but no backward DNS

information, and also describe the desired behaviour.  from Love
<lha@stacken.kth.se>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11395 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2002-09-05 01:36:27 +00:00
parent 231892e586
commit f1feda412e

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999 - 2001 Kungliga Tekniska H<>gskolan
* Copyright (c) 1999 - 2002 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -38,6 +38,14 @@ RCSID("$Id$");
#include "roken.h"
/*
* Try to obtain a verified name for the address in `sa, salen' (much
* similar to getnameinfo).
* Verified in this context means that forwards and backwards lookups
* in DNS are consistent. If that fails, return an error if the
* NI_NAMEREQD flag is set or return the numeric address as a string.
*/
int
getnameinfo_verified(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,
@@ -60,13 +68,13 @@ getnameinfo_verified(const struct sockaddr *sa, socklen_t salen,
ret = getnameinfo (sa, salen, host, hostlen, serv, servlen,
flags | NI_NUMERICSERV);
if (ret)
return ret;
goto fail;
memset (&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
ret = getaddrinfo (host, serv, &hints, &ai);
if (ret)
return ret;
goto fail;
for (a = ai; a != NULL; a = a->ai_next) {
if (a->ai_addrlen == salen
&& memcmp (a->ai_addr, sa, salen) == 0) {
@@ -75,6 +83,7 @@ getnameinfo_verified(const struct sockaddr *sa, socklen_t salen,
}
}
freeaddrinfo (ai);
fail:
if (flags & NI_NAMEREQD)
return EAI_NONAME;
ret = getnameinfo (sa, salen, host, hostlen, serv, servlen,