about summary refs log tree commit diff
path: root/resolv/gethnamaddr.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-07-26 10:14:02 +0000
committerRoland McGrath <roland@gnu.org>1995-07-26 10:14:02 +0000
commit3d61b63cc722951e3a5261e6bc3f0488eb35d441 (patch)
tree19195b08df7f3f992f0d539205df60ff690cd0f6 /resolv/gethnamaddr.c
parent958f803fc021993cc2ee1d4157d0092b830368aa (diff)
downloadglibc-3d61b63cc722951e3a5261e6bc3f0488eb35d441.tar.gz
glibc-3d61b63cc722951e3a5261e6bc3f0488eb35d441.tar.xz
glibc-3d61b63cc722951e3a5261e6bc3f0488eb35d441.zip
* asia, backward, europe, leapseconds, southamerica: New data from
	ADO's 95e.

	* inet/Makefile (routines): Removed inet_addr.
	* inet/inet_addr.c: Moved to resolv/ subdirectory.
	* resolv/Makefile (routines): Added inet_addr.
	* resolv/inet_addr.c: Incorporated from BIND 4.9.3-BETA24 release.
	* resolv/gethnamaddr.c: Likewise.
	* resolv/getnetbyaddr.c: Likewise.
	* resolv/getnetbyname.c: Likewise.
	* resolv/getnetent.c: Likewise.
	* resolv/getnetnamadr.c: Likewise.
	* resolv/herror.c: Likewise.
	* resolv/nsap_addr.c: Likewise.
	* resolv/res_comp.c: Likewise.
	* resolv/res_debug.c: Likewise.
	* resolv/res_init.c: Likewise.
	* resolv/res_mkquery.c: Likewise.
	* resolv/res_query.c: Likewise.
	* resolv/res_send.c: Likewise.
	* resolv/resolv.h: Likewise.
	* resolv/sethostent.c: Likewise.
	* resolv/arpa/nameser.h: Likewise.
	* inet/netdb.h: Incorporated from BIND 4.9.3-BETA24 release.
	[__GNU_LIBRARY__]: Include <rpc/netdb.h> instead of repeating
	its declarations (and doing so only #ifdef sun!).

	* posix/sys/types.h [__USE_BSD] (__BIT_TYPES_DEFINED__): New macro.
	[__USE_BSD] [__GNUC__] (int64_t, u_int64_t, register_t): New typedefs.
Diffstat (limited to 'resolv/gethnamaddr.c')
-rw-r--r--resolv/gethnamaddr.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c
index 55a3fb09a4..d3b68f7d95 100644
--- a/resolv/gethnamaddr.c
+++ b/resolv/gethnamaddr.c
@@ -250,10 +250,12 @@ getanswer(answer, anslen, qname, qclass, qtype)
 			continue;
 		}
 		if (type != qtype) {
-			syslog(LOG_NOTICE|LOG_AUTH,
+			/* CNAME->PTR should not cause a log message. */
+			if (!(qtype == T_PTR && type == T_CNAME))
+				syslog(LOG_NOTICE|LOG_AUTH,
 	       "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
-			       qname, p_class(qclass), p_type(qtype),
-			       p_type(type));
+				       qname, p_class(qclass), p_type(qtype),
+				       p_type(type));
 			cp += n;
 			continue;		/* XXX - had_error++ ? */
 		}
@@ -380,6 +382,11 @@ gethostbyname(name)
 	int n;
 	extern struct hostent *_gethtbyname();
 
+	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+		h_errno = NETDB_INTERNAL;
+		return (NULL);
+	}
+
 	/*
 	 * if there aren't any dots, it could be a user-level alias.
 	 * this is also done in res_query() since we are not the only
@@ -406,7 +413,9 @@ gethostbyname(name)
 					h_errno = HOST_NOT_FOUND;
 					return (NULL);
 				}
-				host.h_name = (char *)name;
+				strncpy(hostbuf, name, MAXDNAME);
+				hostbuf[MAXDNAME] = '\0';
+				host.h_name = hostbuf;
 				host.h_aliases = host_aliases;
 				host_aliases[0] = NULL;
 				host.h_addrtype = AF_INET;
@@ -451,6 +460,10 @@ gethostbyaddr(addr, len, type)
 #endif /*SUNSECURITY*/
 	extern struct hostent *_gethtbyaddr();
 	
+	if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+		h_errno = NETDB_INTERNAL;
+		return (NULL);
+	}
 	if (type != AF_INET) {
 		errno = EAFNOSUPPORT;
 		h_errno = NETDB_INTERNAL;
@@ -480,7 +493,7 @@ gethostbyaddr(addr, len, type)
 	old_options = _res.options;
 	_res.options &= ~RES_DNSRCH;
 	_res.options |= RES_DEFNAMES;
-	if (!(rhp = gethostbyname(hp->h_name))) {
+	if (!(rhp = gethostbyname(hname2))) {
 		syslog(LOG_NOTICE|LOG_AUTH,
 		       "gethostbyaddr: No A record for %s (verifying [%s])",
 		       hname2, inet_ntoa(*((struct in_addr *)addr)));