From watanabe@crayon.planet.kobe-u.ac.jp  Mon Nov 17 08:00:02 1997
Received: from crayon.planet.kobe-u.ac.jp (crayon.planet.kobe-u.ac.jp [133.30.53.130])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id IAA20360
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Nov 1997 08:00:00 -0800 (PST)
          (envelope-from watanabe@crayon.planet.kobe-u.ac.jp)
Received: (from watanabe@localhost) by crayon.planet.kobe-u.ac.jp (8.8.6/3.5Wpl7-mx) id BAA29855; Tue, 18 Nov 1997 01:00:25 +0900 (JST)
Message-Id: <199711171600.BAA29855@crayon.planet.kobe-u.ac.jp>
Date: Tue, 18 Nov 1997 01:00:25 +0900 (JST)
From: watanabe@komadori.planet.kobe-u.ac.jp
Reply-To: watanabe@komadori.planet.kobe-u.ac.jp
To: FreeBSD-gnats-submit@freebsd.org
Subject: /usr/bin/fetch parses a URL incorrectly
X-Send-Pr-Version: 3.2

>Number:         5072
>Category:       bin
>Synopsis:       /usr/bin/fetch parses a URL incorrectly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 17 08:10:01 PST 1997
>Closed-Date:    Wed Feb 3 12:25:01 PST 1999
>Last-Modified:  Wed Feb  3 12:25:11 PST 1999
>Originator:     Takeshi WATANABE
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
Kobe University, Kobe, Japan
>Environment:

  I found a bug on 2.2.2-RELEASE and 2.2.5-RELEASE.  I don't know
on other versions.

>Description:

  According to RFC-1738 and RFC-1808, a HTTP URL has the following format.

	http://<host>:<port>/<path>?<searchpart>

The <host> part cannot contain the colon character (":"), but the <path> part
can.

  Therefore, the following URL is valid.

	http://www.host.name/foo:bar/file.html

"www.host.name" is <host>, and "/foo:bar/file.html" is /<path>. :<port> is
omitted; which means ":80".

  However, /usr/bin/fetch cannot accept this URL.

	prompt> fetch http://www.host.name/foo:bar/file.html
	fetch: `http://www.host.name/foo:bar/file.html': invalid port in URL: Undefined error: 0

So, /usr/bin/fetch parses ":bar" to :<port>. This parsing is incorrect.

  This problem is not so critical, because we avoid this bug to use the
following format.

	prompt> fetch http://www.host.name:80/foo:bar/file.html

/usr/bin/fetch can accept this URL.


  However, it is clear that this is a bug of /usr/bin/fetch.

>How-To-Repeat:

  Always when we use /usr/bin/fetch with a HTTP URL that contains the colon
character (":") in the path name.

>Fix:

  Apply the following patch.

--- /usr/src/usr.bin/fetch/http.c.orig	Mon Mar 10 16:12:51 1997
+++ /usr/src/usr.bin/fetch/http.c	Tue Nov 18 00:21:52 1997
@@ -152,7 +152,7 @@
 	strncat(hostname, p, q - p);
 	p = slash;
 
-	if (colon && colon + 1 != slash) {
+	if (q == colon && colon + 1 != slash) {
 		unsigned long ul;
 		char *ep;
 
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: fenner 
State-Changed-When: Wed Feb 3 12:25:01 PST 1999 
State-Changed-Why:  
Committed, thanks! 
>Unformatted:
