From owner-freebsd-bugs Fri Jan 10 6:10: 6 2003 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 96DBC37B401 for ; Fri, 10 Jan 2003 06:10:04 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4AE0243F13 for ; Fri, 10 Jan 2003 06:10:04 -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 h0AEA3NS037963 for ; Fri, 10 Jan 2003 06:10:03 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h0AEA3SS037961; Fri, 10 Jan 2003 06:10:03 -0800 (PST) Date: Fri, 10 Jan 2003 06:10:03 -0800 (PST) Message-Id: <200301101410.h0AEA3SS037961@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Denis N. Peplin" Subject: Re: bin/37343: portmap TCP binds strangeness Reply-To: "Denis N. Peplin" 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 bin/37343; it has been noted by GNATS. From: "Denis N. Peplin" To: freebsd-gnats-submit@FreeBSD.org, marck@rinet.ru Cc: Subject: Re: bin/37343: portmap TCP binds strangeness Date: Fri, 10 Jan 2003 17:12:13 +0300 Yet another hack. Index: portmap.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/portmap/Attic/portmap.c,v retrieving revision 1.10.2.3 diff -u -r1.10.2.3 portmap.c --- portmap.c 6 May 2002 18:18:21 -0000 1.10.2.3 +++ portmap.c 10 Jan 2003 14:01:47 -0000 @@ -119,6 +119,7 @@ int sock, c; char **hosts = NULL; int nhosts = 0; + int nhosts2 = 0; struct sockaddr_in addr; int len = sizeof(struct sockaddr_in); register struct pmaplist *pml; @@ -165,7 +166,7 @@ hosts[0] = "0.0.0.0"; else hosts[nhosts - 1] = "127.0.0.1"; - + nhosts2 = nhosts; /* * Add UDP socket(s) - bind to specific IPs if asked to */ @@ -203,7 +204,14 @@ /* * Add TCP socket */ - addr.sin_addr.s_addr = 0; + nhosts = nhosts2; + while (nhosts > 0) { + --nhosts; + + if (!inet_aton(hosts[nhosts], &addr.sin_addr)) { + syslog(LOG_ERR, "bad IP address: %s", hosts[nhosts]); + exit(1); + } if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { syslog(LOG_ERR, "cannot create tcp socket: %m"); exit(1); @@ -216,6 +224,7 @@ == (SVCXPRT *)NULL) { syslog(LOG_ERR, "couldn't do tcp_create"); exit(1); + } } /* make an entry for ourself */ pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message