Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Nov 2002 18:32:34 -0800 (PST)
From:      frf@xocolatl.com
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/45659: portmap can not be bound to only loopback
Message-ID:  <200211240232.gAO2WYAB078181@mleko.xocolatl.com>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211240232.gAO2WYAB078181>