From owner-freebsd-bugs Sat Nov 23 18:40: 8 2002 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 819C437B401 for ; Sat, 23 Nov 2002 18:40:03 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 116EA43E6E for ; Sat, 23 Nov 2002 18:40:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gAO2e1x3064827 for ; Sat, 23 Nov 2002 18:40:01 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gAO2e1Xp064826; Sat, 23 Nov 2002 18:40:01 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 40BD837B401 for ; Sat, 23 Nov 2002 18:32:43 -0800 (PST) Received: from mleko.xocolatl.com (xocolatl.com [216.240.48.11]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CA0C43E9C for ; Sat, 23 Nov 2002 18:32:42 -0800 (PST) (envelope-from frf@xocolatl.com) Received: from mleko.xocolatl.com (localhost [127.0.0.1]) by mleko.xocolatl.com (8.12.6/8.12.6) with ESMTP id gAO2WgWE078182 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 23 Nov 2002 18:32:42 -0800 (PST) (envelope-from frf@mleko.xocolatl.com) Received: (from frf@localhost) by mleko.xocolatl.com (8.12.6/8.12.6/Submit) id gAO2WYAB078181; Sat, 23 Nov 2002 18:32:34 -0800 (PST) (envelope-from frf) Message-Id: <200211240232.gAO2WYAB078181@mleko.xocolatl.com> Date: Sat, 23 Nov 2002 18:32:34 -0800 (PST) From: frf@xocolatl.com Reply-To: frf@xocolatl.com To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/45659: portmap can not be bound to only loopback 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 >Number: 45659 >Category: bin >Synopsis: portmap can not be bound to only loopback >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Nov 23 18:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Robert Faulds >Release: FreeBSD 4.7-STABLE i386 >Organization: >Environment: System: FreeBSD mleko.xocolatl.com 4.7-STABLE FreeBSD 4.7-STABLE #43: Fri Nov 15 05:20:16 PST 2002 frf@mleko.xocolatl.com:/usr/obj/usr/src/sys/MLEKO i386 >Description: portmap.c contains a bug that will not allow one to bind portmap to only the loopback interface with the -h flag. If -h 127.0.0.1 is used, the array containing addresses to bind to will contain 127.0.0.1 twice. This produces and error causing portmap to exit. >How-To-Repeat: portmap -h 127.0.0.1 >Fix: --- /usr/src/usr.sbin/portmap/portmap.c-orig Sat Nov 23 17:01:29 2002 +++ /usr/src/usr.sbin/portmap/portmap.c Sat Nov 23 18:19:02 2002 @@ -119,6 +119,7 @@ int sock, c; char **hosts = NULL; int nhosts = 0; + int ihost; struct sockaddr_in addr; int len = sizeof(struct sockaddr_in); register struct pmaplist *pml; @@ -157,14 +158,19 @@ /* * If no hosts were specified, just bind to INADDR_ANY. Otherwise - * make sure 127.0.0.1 is added to the list. + * make sure 127.0.0.1 is added to the list, unless 127.0.0.1 is + * already there. */ + for ( ihost = 0; ihost < nhosts; ihost++ ) + if ( !strncmp( "127.0.0.1", hosts[ihost], 16 ) ) + goto lAlready; ++nhosts; hosts = realloc(hosts, nhosts * sizeof(char *)); if (nhosts == 1) hosts[0] = "0.0.0.0"; else hosts[nhosts - 1] = "127.0.0.1"; + lAlready: /* * Add UDP socket(s) - bind to specific IPs if asked to --- /usr/src/usr.sbin/portmap/portmap.8-orig Sat Nov 23 17:35:20 2002 +++ /usr/src/usr.sbin/portmap/portmap.8 Sat Nov 23 17:36:25 2002 @@ -126,7 +126,7 @@ .Nm will automatically add .Li 127.0.0.1 -to the list. +to the list unless it's already there. .El .Sh SEE ALSO .Xr hosts_access 5 , >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message