From owner-freebsd-bugs@FreeBSD.ORG Mon May 5 22:30:17 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 548E337B401 for ; Mon, 5 May 2003 22:30:17 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B5BF343FAF for ; Mon, 5 May 2003 22:30:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h465U9Up070569 for ; Mon, 5 May 2003 22:30:09 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h465U9GQ070568; Mon, 5 May 2003 22:30:09 -0700 (PDT) Resent-Date: Mon, 5 May 2003 22:30:09 -0700 (PDT) Resent-Message-Id: <200305060530.h465U9GQ070568@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Mark Andrews Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C4B2837B404 for ; Mon, 5 May 2003 22:26:56 -0700 (PDT) Received: from bsdi.dv.isc.org (c17249.carlnfd1.nsw.optusnet.com.au [210.49.138.109]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2F94943FD7 for ; Mon, 5 May 2003 22:26:55 -0700 (PDT) (envelope-from marka@isc.org) Received: from drugs.dv.isc.org (drugs.dv.isc.org [192.168.191.236]) by bsdi.dv.isc.org (8.12.9/8.12.9) with ESMTP id h465Qrab068405 for ; Tue, 6 May 2003 15:26:53 +1000 (EST) (envelope-from marka@isc.org) Received: from drugs.dv.isc.org (localhost [127.0.0.1]) by drugs.dv.isc.org (8.12.9/8.12.9) with ESMTP id h465Qr1G037638 for ; Tue, 6 May 2003 15:26:53 +1000 (EST) (envelope-from marka@drugs.dv.isc.org) Received: (from marka@localhost) by drugs.dv.isc.org (8.12.9/8.12.9/Submit) id h465QqT3037637; Tue, 6 May 2003 15:26:52 +1000 (EST) (envelope-from marka) Message-Id: <200305060526.h465QqT3037637@drugs.dv.isc.org> Date: Tue, 6 May 2003 15:26:52 +1000 (EST) From: Mark Andrews To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/51827: getaddrinfo() is broken with numeric service X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Mark Andrews List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2003 05:30:17 -0000 >Number: 51827 >Category: bin >Synopsis: getaddrinfo() is broken with numeric service >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 05 22:30:09 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Mark Andrews >Release: FreeBSD 4.8-RC i386 >Organization: ISC >Environment: System: FreeBSD drugs.dv.isc.org 4.8-RC FreeBSD 4.8-RC #6: Sun Mar 30 11:45:29 EST 2003 marka@drugs.dv.isc.org:/usr/obj/usr/src/sys/DRUGS i386 >Description: getaddrinfo() should accept numeric when ai_socktype is not specified in hint or hints is NULL. RFC 3493: If servname is null, the call shall return network-level addresses for the specified nodename. If servname is not null, it is a null- terminated character string identifying the requested service. This can be either a descriptive name or a numeric representation suitable for use with the address family or families. If the specified address family is AF_INET, AF_INET6 or AF_UNSPEC, the service can be specified as a string specifying a decimal port number. While I havn't checked the posix spec nothing in RFC 3493 indicates that numeric values are only to be accepted when ai_socktype is specified. >How-To-Repeat: % ./a.out 53/NULL servname not supported for ai_socktype 53/hint servname not supported for ai_socktype domain/hint 28 2 17 2 2 17 28 1 6 2 1 6 domain/hint 28 2 17 2 2 17 28 1 6 2 1 6 % #include #include #include #include main() { int error; struct addrinfo *res, *res0; struct addrinfo hint; memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_UNSPEC; printf("53/NULL\n"); error = getaddrinfo("rc.isc.org", "53", NULL, &res0); if (error) { printf("%s\n", gai_strerror(error)); } else { for (res = res0; res; res = res->ai_next) { printf("%d %u %u\n", res->ai_family, res->ai_socktype, res->ai_protocol); } freeaddrinfo(res0); } printf("53/hint\n"); error = getaddrinfo("rc.isc.org", "53", &hint, &res0); if (error) { printf("%s\n", gai_strerror(error)); } else { for (res = res0; res; res = res->ai_next) { printf("%d %u %u\n", res->ai_family, res->ai_socktype, res->ai_protocol); } freeaddrinfo(res0); } printf("domain/hint\n"); error = getaddrinfo("rc.isc.org", "domain", NULL, &res0); if (error) { printf("%s\n", gai_strerror(error)); } else { for (res = res0; res; res = res->ai_next) { printf("%d %u %u\n", res->ai_family, res->ai_socktype, res->ai_protocol); } freeaddrinfo(res0); } printf("domain/hint\n"); error = getaddrinfo("rc.isc.org", "domain", &hint, &res0); if (error) { printf("%s\n", gai_strerror(error)); } else { for (res = res0; res; res = res->ai_next) { printf("%d %u %u\n", res->ai_family, res->ai_socktype, res->ai_protocol); } freeaddrinfo(res0); } exit(0); } >Fix: The following if from the BIND 8 source but should apply. Index: lib/irs/getaddrinfo.c =================================================================== RCS file: /proj/cvs/isc/bind8/src/lib/irs/getaddrinfo.c,v retrieving revision 8.12 diff -u -r8.12 getaddrinfo.c --- lib/irs/getaddrinfo.c 3 Dec 2002 05:26:49 -0000 8.12 +++ lib/irs/getaddrinfo.c 6 May 2003 05:10:26 -0000 @@ -987,7 +987,17 @@ allownumeric = 1; break; case ANY: - allownumeric = 0; + switch (ai->ai_family) { + case AF_INET: +#ifdef AF_INET6 + case AF_INET6: +#endif + allownumeric = 1; + break; + default: + allownumeric = 0; + break; + } break; default: return EAI_SOCKTYPE; >Release-Note: >Audit-Trail: >Unformatted: