From c90026255aee70d47152f42153afe2d329f7a8c1 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Thu, 4 Jul 2002 10:08:01 +0000 Subject: use tcp high portrange for active data connections. ok deraadt@ --- usr.bin/ftp/ftp.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'usr.bin/ftp') diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index dc4b122ae33..60bdb186ea1 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp.c,v 1.48 2002/06/09 02:36:03 itojun Exp $ */ +/* $OpenBSD: ftp.c,v 1.49 2002/07/04 10:08:00 jakob Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* @@ -67,7 +67,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: ftp.c,v 1.48 2002/06/09 02:36:03 itojun Exp $"; +static char rcsid[] = "$OpenBSD: ftp.c,v 1.49 2002/07/04 10:08:00 jakob Exp $"; #endif #endif /* not lint */ @@ -1415,6 +1415,20 @@ noport: warn("setsockopt (reuse address)"); goto bad; } + switch (data_addr.su_family) { + case AF_INET: + on = IP_PORTRANGE_HIGH; + if (setsockopt(data, IPPROTO_IP, IP_PORTRANGE, + (char *)&on, sizeof(on)) < 0) + warn("setsockopt IP_PORTRANGE (ignored)"); + break; + case AF_INET6: + on = IPV6_PORTRANGE_HIGH; + if (setsockopt(data, IPPROTO_IPV6, IPV6_PORTRANGE, + (char *)&on, sizeof(on)) < 0) + warn("setsockopt IPV6_PORTRANGE (ignored)"); + break; + } if (bind(data, (struct sockaddr *)&data_addr, data_addr.su_len) < 0) { warn("bind"); goto bad; -- cgit v1.2.3