Module Name:    src
Committed By:   christos
Date:           Mon Dec 14 22:07:37 UTC 2015

Modified Files:
        src/lib/libc/net: getaddrinfo.c

Log Message:
PR/50552: Kyle Amon: RFC3493 section 6.1 wants us to accept non-dotted-quad
INET4 addresses.
XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/lib/libc/net/getaddrinfo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/net/getaddrinfo.c
diff -u src/lib/libc/net/getaddrinfo.c:1.112 src/lib/libc/net/getaddrinfo.c:1.113
--- src/lib/libc/net/getaddrinfo.c:1.112	Sat Dec 12 21:02:59 2015
+++ src/lib/libc/net/getaddrinfo.c	Mon Dec 14 17:07:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: getaddrinfo.c,v 1.112 2015/12/13 02:02:59 christos Exp $	*/
+/*	$NetBSD: getaddrinfo.c,v 1.113 2015/12/14 22:07:37 christos Exp $	*/
 /*	$KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $	*/
 
 /*
@@ -55,7 +55,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.112 2015/12/13 02:02:59 christos Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.113 2015/12/14 22:07:37 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -1312,8 +1312,15 @@ explore_numeric(const struct addrinfo *p
 		return 0;
 
 	switch (afd->a_af) {
-#if 0 /*X/Open spec*/
 	case AF_INET:
+	       /*
+		* RFC3493 section 6.1, requires getaddrinfo() to accept
+		* AF_INET formats that are accepted by inet_addr(); here
+		* we use the equivalent inet_aton() function so we can
+		* check for errors. inet_pton() only accepts addresses
+		* in the dotted quad format and only in base 10, so we
+		* need to treat AF_INET specially.
+		*/
 		if (inet_aton(hostname, (struct in_addr *)pton) == 1) {
 			if (pai->ai_family == afd->a_af ||
 			    pai->ai_family == PF_UNSPEC /*?*/) {
@@ -1333,7 +1340,6 @@ explore_numeric(const struct addrinfo *p
 				ERR(EAI_FAMILY);	/*xxx*/
 		}
 		break;
-#endif
 	default:
 		if (inet_pton(afd->a_af, hostname, pton) == 1) {
 			if (pai->ai_family == afd->a_af ||

Reply via email to