From owner-freebsd-bugs@FreeBSD.ORG Mon Jul 28 09:40:58 2003 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3700137B401; Mon, 28 Jul 2003 09:40:58 -0700 (PDT) Received: from cs.columbia.edu (cs.columbia.edu [128.59.16.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49A3B43F75; Mon, 28 Jul 2003 09:40:57 -0700 (PDT) (envelope-from lennox@grandcentral.cs.columbia.edu) Received: from grandcentral.cs.columbia.edu (grandcentral.cs.columbia.edu [128.59.19.196]) by cs.columbia.edu (8.12.9/8.12.9) with ESMTP id h6SGesl8021729 verify=NOT); Mon, 28 Jul 2003 12:40:55 -0400 (EDT) Received: from grandcentral.cs.columbia.edu (localhost [127.0.0.1]) h6SGerQQ009574; Mon, 28 Jul 2003 12:40:53 -0400 (EDT) Received: (from lennox@localhost)h6SGequu009571; Mon, 28 Jul 2003 12:40:52 -0400 (EDT) From: Jonathan Lennox MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="p4dH/IeS7Q" Content-Transfer-Encoding: 7bit Message-ID: <16165.21011.781126.341394@grandcentral.cs.columbia.edu> Date: Mon, 28 Jul 2003 12:40:51 -0400 To: sub_0@netcabo.pt In-Reply-To: <1058576063.1430.20.camel@suzy.unbreakable.homeunix.org> References: <1058576063.1430.20.camel@suzy.unbreakable.homeunix.org> X-Mailer: VM 7.17 under Emacs 20.7.1 cc: freebsd-bugs@FreeBSD.org cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: misc/54189: DNS resolver should resolve hostnames with underscores X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2003 16:40:58 -0000 --p4dH/IeS7Q Content-Type: text/plain; charset=iso-8859-1 Content-Description: message body text Content-Transfer-Encoding: quoted-printable On , July 19 2003, "M=E1rio Freitas" wrote to "freebsd-bugs@FreeBSD.org= , lennox@cs.columbia.edu" saying: > The problem you submitted is due to mozilla's gethostbyname() own(bad= ) > implementation. FreeBSD's resolver can deal with underscores in > hostnames without any problem at all. I think you should submit that > problem to mozilla's bug tracking system(yes I succeded resolving tha= t > hostname in FreeBSD 4.8 and 5.1). Not so, at least if you go through the gethostbyname() or getaddrinfo()= APIs. I've attached a small program that exercises both APIs, compiled= it on both FreeBSD 4.8-RELEASE and on Red Hat Linux 7.1, and executed b= oth on the same FreeBSD 4.8 machine (the Linux binary running under emulati= on): conrail $ ./gethostbyname dear=5Fraed.blogspot.com dear=5Fraed.blogspot.com: gethostbyname lookup failed: Unknown server e= rror (3) dear=5Fraed.blogspot.com: getaddrinfo lookup failed: Non-recoverable fa= ilure in name resolution (4) conrail $ ./gethostbyname-linux dear=5Fraed.blogspot.com dear=5Fraed.blogspot.com [ghbn]: 216.34.7.189=20 dear=5Fraed.blogspot.com [gai]: 216.34.7.189 216.34.7.189 216.34.7.189=20= The FreeBSD 'nslookup' and 'host' programs, which bypass these APIs and= do DNS queries directly, can indeed resolve the hostname: conrail $ nslookup dear=5Fraed.blogspot.com Server: sutton.cs.columbia.edu Address: 128.59.22.38 Non-authoritative answer: Name: dear=5Fraed.blogspot.com Address: 216.34.7.189 conrail $ host dear=5Fraed.blogspot.com dear=5Fraed.blogspot.com has address 216.34.7.189 --p4dH/IeS7Q Content-Type: text/plain Content-Disposition: inline; filename="gethostbyname.c" Content-Transfer-Encoding: 7bit #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int i; struct addrinfo hints; if (argc < 2) { fprintf(stderr, "Usage: %s hostname [...]", argv[0]); exit(1); } memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; for (i = 1; i < argc; i++) { int ret; struct hostent *he; struct addrinfo *ai; he = gethostbyname(argv[i]); if (he == NULL) { printf("%s: gethostbyname lookup failed: %s (%d)\n", argv[i], hstrerror(h_errno), h_errno); } else { int j; printf("%s [ghbn]: ", argv[i]); for (j = 0; he->h_addr_list[j] != NULL; j++) { printf("%s ", inet_ntoa(*(struct in_addr*)(he->h_addr_list[j]))); } printf("\n"); } ret = getaddrinfo(argv[i], NULL, &hints, &ai); if (ret != 0) { printf("%s: getaddrinfo lookup failed: %s (%d)\n", argv[i], gai_strerror(ret), ret); } else { struct addrinfo* this_ai; printf("%s [gai]: ", argv[i]); for (this_ai = ai; this_ai != NULL; this_ai = this_ai->ai_next) { printf("%s ", inet_ntoa(((struct sockaddr_in*)(this_ai->ai_addr))->sin_addr)); } printf("\n"); freeaddrinfo(ai); } } return 0; } --p4dH/IeS7Q Content-Type: text/plain; charset=us-ascii Content-Description: .signature Content-Transfer-Encoding: 7bit -- Jonathan Lennox lennox@cs.columbia.edu --p4dH/IeS7Q--