From b5dda3e238cd15f90e4171ce66c5298e6b9379a3 Mon Sep 17 00:00:00 2001 From: itojun Date: Mon, 17 Mar 2003 23:10:25 +0000 Subject: [PATCH] From: "Jason L. Wright" The man page for getaddrinfo() and RFC2553 says it should return EAI_NONAME for the case where hostname != NULL, hostname is not a numeric string and ai_flags has the AI_NUMERICHOST bit set. Instead, it returns EAI_NODATA for this case. The diff below makes it return EAI_NONAME for this case. This is why ntpq and ntpdc from ntp-4.1.74 can't resolve hostnames, but work fine with numeric strings like ::1 or 127.0.0.1. --- lib/libc/net/getaddrinfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index cc39c6255a74..f74b80148285 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.63 2002/08/27 08:50:49 itojun Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.64 2003/03/17 23:10:25 itojun Exp $ */ /* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */ /* @@ -79,7 +79,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getaddrinfo.c,v 1.63 2002/08/27 08:50:49 itojun Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.64 2003/03/17 23:10:25 itojun Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -500,10 +500,10 @@ getaddrinfo(hostname, servname, hints, res) if (sentinel.ai_next) goto good; - if (pai->ai_flags & AI_NUMERICHOST) - ERR(EAI_NODATA); if (hostname == NULL) ERR(EAI_NODATA); + if (pai->ai_flags & AI_NUMERICHOST) + ERR(EAI_NONAME); /* * hostname as alphabetical name.