summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2006-07-21 19:02:28 +0000
committerume <ume@FreeBSD.org>2006-07-21 19:02:28 +0000
commit636a28fc7515b76a295e7dbd13d3e2448831f7b8 (patch)
tree3abb43bd33921b7ad8a5357e0aafa8cbcc500f7c /lib
parent34bbbddd7edea08765b37576afc0456076006a6c (diff)
downloadFreeBSD-src-636a28fc7515b76a295e7dbd13d3e2448831f7b8.zip
FreeBSD-src-636a28fc7515b76a295e7dbd13d3e2448831f7b8.tar.gz
simplification in explore_numeric: unified the post-process with
GET_AI and GET_PORT. Commented on an impossible case. Obtained from: KAME MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/getaddrinfo.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 21f65ac..e673efa 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1139,43 +1139,33 @@ explore_numeric(const struct addrinfo *pai, const char *hostname,
* does not accept. So we need to separate the case for
* AF_INET.
*/
- if (inet_aton(hostname, (struct in_addr *)pton) == 1) {
- if (pai->ai_family == afd->a_af ||
- pai->ai_family == PF_UNSPEC /*?*/) {
- GET_AI(ai, afd, pton);
- GET_PORT(ai, servname);
- if ((pai->ai_flags & AI_CANONNAME)) {
- /*
- * Set the numeric address itself as
- * the canonical name, based on a
- * clarification in rfc3493.
- */
- GET_CANONNAME(ai, canonname);
- }
- } else
- ERR(EAI_FAMILY); /*xxx*/
- }
+ if (inet_aton(hostname, (struct in_addr *)pton) != 1)
+ return 0;
break;
default:
- if (inet_pton(afd->a_af, hostname, pton) == 1) {
- if (pai->ai_family == afd->a_af ||
- pai->ai_family == PF_UNSPEC /*?*/) {
- GET_AI(ai, afd, pton);
- GET_PORT(ai, servname);
- if ((pai->ai_flags & AI_CANONNAME)) {
- /*
- * Set the numeric address itself as
- * the canonical name, based on a
- * clarification in rfc3493.
- */
- GET_CANONNAME(ai, canonname);
- }
- } else
- ERR(EAI_FAMILY); /* XXX */
- }
+ if (inet_pton(afd->a_af, hostname, pton) != 1)
+ return 0;
break;
}
+ if (pai->ai_family == afd->a_af) {
+ GET_AI(ai, afd, pton);
+ GET_PORT(ai, servname);
+ if ((pai->ai_flags & AI_CANONNAME)) {
+ /*
+ * Set the numeric address itself as the canonical
+ * name, based on a clarification in RFC3493.
+ */
+ GET_CANONNAME(ai, canonname);
+ }
+ } else {
+ /*
+ * XXX: This should not happen since we already matched the AF
+ * by find_afd.
+ */
+ ERR(EAI_FAMILY);
+ }
+
*res = ai;
return 0;
OpenPOWER on IntegriCloud