Date: Thu, 12 Aug 1999 14:38:39 +0200 (CEST) From: Paul.Hernaus@nl.origin-it.com To: FreeBSD-gnats-submit@freebsd.org Subject: bin/13092: Fetch doesn't default to the correct http-port when no port is specified in the environment Message-ID: <19990812123839.64135702C@itchy.mpn.cp.philips.com>
next in thread | raw e-mail | index | archive | help
>Number: 13092 >Category: bin >Synopsis: Fetch doesn't default to the correct http-port when no port is specifie d in the environment >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: Thu Aug 12 05:40:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Paul Hernaus >Release: FreeBSD 3.2-STABLE i386 >Organization: Origin Nederland B.V. >Environment: stable as of now >Description: [~] paul@itchy> setenv HTTP_PROXY www-proxy.mpn.cp.philips.com [~] paul@itchy> fetch http://www.freebsd.org/index.html fetch: sendmsg: www-proxy.mpn.cp.philips.com: Can't assign requested address [~] paul@itchy> >How-To-Repeat: See above >Fix: Apply the following patch against stable. Note that this also fixes a missing dependency on fetch.h. diff -u /usr/src/usr.bin/fetch/Makefile /tmp/fetch/Makefile --- /usr/src/usr.bin/fetch/Makefile Thu Jan 30 22:43:35 1997 +++ /tmp/fetch/Makefile Thu Aug 12 14:15:51 1999 @@ -1,5 +1,5 @@ PROG = fetch -SRCS = file.c ftp.c http.c main.c util.c uri.c +SRCS = fetch.h file.c ftp.c http.c main.c util.c uri.c CFLAGS+= -Wall -Wwrite-strings -Wmissing-prototypes diff -u /usr/src/usr.bin/fetch/fetch.h /tmp/fetch/fetch.h --- /usr/src/usr.bin/fetch/fetch.h Tue Dec 8 14:00:49 1998 +++ /tmp/fetch/fetch.h Thu Aug 12 14:16:05 1999 @@ -37,6 +37,9 @@ #define FETCH_VERSION "fetch/1.0" #define PATH_CP "/bin/cp" +#define DEFAULT_FTP_PORT 21 +#define DEFAULT_HTTP_PORT 80 + struct fetch_state { const char *fs_status; const char *fs_outputfile; diff -u /usr/src/usr.bin/fetch/ftp.c /tmp/fetch/ftp.c --- /usr/src/usr.bin/fetch/ftp.c Fri Jun 25 04:57:24 1999 +++ /tmp/fetch/ftp.c Thu Aug 12 14:13:21 1999 @@ -117,7 +117,7 @@ port = ul; } else { - port = 21; + port = DEFAULT_FTP_PORT; } p = slash + 1; @@ -253,7 +253,7 @@ hostname = getenv("FTP_PROXY"); port = strchr(hostname, ':'); if (port == 0) { - portno = 21; + portno = DEFAULT_FTP_PORT; } else { unsigned long ul; char *ep; @@ -289,12 +289,13 @@ user = ftps->ftp_user ? ftps->ftp_user : "anonymous"; /* user @ hostname [ @port ] \0 */ newuser = safe_malloc(strlen(user) + 1 + strlen(ftps->ftp_hostname) - + ((ftps->ftp_port != 21) ? 6 : 0) + 1); + + ((ftps->ftp_port != DEFAULT_FTP_PORT) ? 6 : 0) + + 1); strcpy(newuser, user); strcat(newuser, "@"); strcat(newuser, ftps->ftp_hostname); - if (ftps->ftp_port != 21) { + if (ftps->ftp_port != DEFAULT_FTP_PORT) { char numbuf[6]; snprintf(numbuf, sizeof(numbuf), "%d", ftps->ftp_port); diff -u /usr/src/usr.bin/fetch/http.c /tmp/fetch/http.c --- /usr/src/usr.bin/fetch/http.c Fri Jun 25 04:57:26 1999 +++ /tmp/fetch/http.c Thu Aug 12 14:12:19 1999 @@ -179,7 +179,7 @@ port = ul; } else { - port = 80; + port = DEFAULT_HTTP_PORT; } p = slash; @@ -476,7 +476,9 @@ memset(&sin, 0, sizeof sin); sin.sin_family = AF_INET; sin.sin_len = sizeof sin; - sin.sin_port = htons(https->http_port); + sin.sin_port = htons(https->http_port != 0 + ? https->http_port + : DEFAULT_HTTP_PORT); fs->fs_status = "looking up hostname"; if (inet_aton(https->http_hostname, &sin.sin_addr) == 0) { >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?19990812123839.64135702C>