From owner-freebsd-bugs Fri Mar 23 13:50:18 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A73FB37B71A for ; Fri, 23 Mar 2001 13:50:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f2NLo1435735; Fri, 23 Mar 2001 13:50:01 -0800 (PST) (envelope-from gnats) Received: from mrout2.yahoo.com (mrout2.yahoo.com [216.145.54.172]) by hub.freebsd.org (Postfix) with ESMTP id 47BB237B71A for ; Fri, 23 Mar 2001 13:45:05 -0800 (PST) (envelope-from peter@daintree.yahoo.com) Received: from daintree.yahoo.com (daintree.yahoo.com [205.216.162.172]) by mrout2.yahoo.com (8.11.1/8.11.1/y.out) with ESMTP id f2NLiuI54002 for ; Fri, 23 Mar 2001 13:44:56 -0800 (PST) Received: (from peter@localhost) by daintree.yahoo.com (8.11.3/8.11.3) id f2NLiuS81327; Fri, 23 Mar 2001 13:44:56 -0800 (PST) (envelope-from peter) Message-Id: <200103232144.f2NLiuS81327@daintree.yahoo.com> Date: Fri, 23 Mar 2001 13:44:56 -0800 (PST) From: Peter Wemm Reply-To: peter@yahoo-inc.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/26038: libfetch does not use IP_PORTRANGE_HIGH by default Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 26038 >Category: bin >Synopsis: libfetch does not use IP_PORTRANGE_HIGH by default >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Mar 23 13:50:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Peter Wemm >Release: FreeBSD 5.0-CURRENT i386 >Organization: FreeBSD.org >Environment: System: FreeBSD daintree.yahoo.com 5.0-CURRENT FreeBSD 5.0-CURRENT #21: Mon Mar 19 13:09:28 PST 2001 peter@daintree.yahoo.com:/home/src/sys/compile/DAINTREE i386 FreeBSD-current as of a few days ago. >Description: The old fetch(1)/libftpio library unconditionally used the RFC sanctioned high port range. This space is intentionally intended to be used so that proxy libraries can rewrite the PORT tcp packets on data streams on NATs, and so that firewalls have a safe target range that can allow incoming connections that is free from the ephemeral ports that are used by things like rpc services. The new fetch/libfetch has regressed to requiring an option to use this. >How-To-Repeat: Old code (unconditional use of IP_PORTRANGE_HIGH): portrange = IP_PORTRANGE_HIGH; if (setsockopt(s, IPPROTO_IP, IP_PORTRANGE, (char *) &portrange, sizeof(portrange)) < 0) { close(s); return FAILURE; }; New code (broken): high = CHECK_FLAG('h'); arg = high ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT; if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, (char *)&arg, sizeof arg) == -1) goto sysouch; break; (where the 'h' flag is off by default :-( ) >Fix: Minimal fix, minus man page and some comment updates. Index: fetch.c =================================================================== RCS file: /home/ncvs/src/usr.bin/fetch/fetch.c,v retrieving revision 1.26 diff -u -r1.26 fetch.c --- fetch.c 2001/03/07 05:33:50 1.26 +++ fetch.c 2001/03/23 21:43:39 @@ -55,7 +55,7 @@ int d_flag; /* -d: direct connection */ int F_flag; /* -F: restart without checking mtime */ char *f_filename; /* -f: file to fetch */ -int H_flag; /* -H: use high port */ +int H_flag = 1; /* -H: use high port */ char *h_hostname; /* -h: host to fetch from */ int l_flag; /* -l: link rather than copy file: URLs */ int m_flag; /* -[Mm]: mirror mode */ @@ -537,7 +537,7 @@ int c, e, r; while ((c = getopt(argc, argv, - "146AaB:bc:dFf:h:lHMmnPpo:qRrS:sT:tvw:")) != EOF) + "146AaB:bc:dFf:h:lHMmnPpo:qRrS:sT:tUvw:")) != EOF) switch (c) { case '1': once_flag = 1; @@ -625,6 +625,9 @@ case 't': t_flag = 1; warnx("warning: the -t option is deprecated"); + break; + case 'U': + H_flag = 0; break; case 'v': v_level++; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message