From frf@xocolatl.com  Sat Nov 23 18:32:43 2002
Return-Path: <frf@xocolatl.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 40BD837B401
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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
Cc:
Subject: portmap can not be bound to only loopback
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         45659
>Category:       bin
>Synopsis:       portmap can not be bound to only loopback
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 23 18:40:01 PST 2002
>Closed-Date:    Sun Jul 18 08:17:11 GMT 2004
>Last-Modified:  Sun Jul 18 08:17:11 GMT 2004
>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:
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Sun Jul 18 08:16:28 GMT 2004 
State-Changed-Why:  
Duplicate of bin/30235.  Thanks for the submission anyway! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45659 
>Unformatted:
