From owner-freebsd-bugs Wed Aug 29 6:30: 6 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 4C2A237B403 for ; Wed, 29 Aug 2001 06:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f7TDU2v11730; Wed, 29 Aug 2001 06:30:02 -0700 (PDT) (envelope-from gnats) Date: Wed, 29 Aug 2001 06:30:02 -0700 (PDT) Message-Id: <200108291330.f7TDU2v11730@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: David Malone Subject: Re: misc/30186: getaddrinfo does not handle incorrect servname Reply-To: David Malone Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/30186; it has been noted by GNATS. From: David Malone To: John Morrow Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: misc/30186: getaddrinfo does not handle incorrect servname Date: Wed, 29 Aug 2001 14:23:38 +0100 On Wed, Aug 29, 2001 at 03:28:56AM -0700, John Morrow wrote: > >Description: > If I call getaddrinfo("127.0.0.1", "80", &hints, &res) as a non-root > user and then bind using the returned socket address structure my > program is bound to the wrong address and port. I would have expected > a correctly filled out socket address structure and then a EACCESS > from bind(2). Bind(2) is returning -1 and setting errno to EACCESS, but you didn't check the return value from bind, so your program didn't notice. Then, when you call listen(2), an ephemeral port is assigned to your program so that it can listen. > Also putting negative or high port numbers into this program > never causes getaddrinfo to return an error. I guess that's another issue - I assume it's taking them mod 65536. David. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message