Subject: bin/13768: ftp does not handle URLs with no file correctly
To: None <gnats-bugs@gnats.netbsd.org>
From: None <anders@dinsen.net>
List: netbsd-bugs
Date: 08/22/2001 23:01:52
>Number:         13768
>Category:       bin
>Synopsis:       ftp does not handle URLs with no file correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 22 13:58:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Anders Dinsen
>Release:        1.5
>Organization:
Anders Dinsen
anders@dinsen.net
http://dinsen.net/anders/
>Environment:
System: NetBSD kvik 1.5 NetBSD 1.5 (KVIK) #4: Mon Jun 18 10:49:51 CEST 2001 anders@kvik:/amd/box/usr/src/sys/arch/i386/compile/KVIK i386


>Description:
Specifying an output file with -o disables the check for a file name
part of the URL. Giving an HTTP URL without a file name causes ftp
to produce a bad HTTP GET request.

E.g.:

ftp -o - http://dinsen.net

produces this nonsense request line:

GET  HTTP/1.1
>How-To-Repeat:
Apache servers just ignores the request:

ftp -o - http://www.netbsd.org
ftp: Improper response from `www.netbsd.org'

IIS servers are actually more informative:

ftp -o - http://www.microsoft.com
ftp: Error retrieving file - `400 Bad Request'
>Fix:
--- fetch.c.orig	Wed Aug 22 22:55:58 2001
+++ fetch.c	Wed Aug 22 22:55:14 2001
@@ -409,7 +409,7 @@
 	if (tport != NULL)
 		*port = xstrdup(tport);
 	if (*path == NULL)
-		*path = xstrdup("");
+		*path = xstrdup("/");
 
 	if (debug)
 		fprintf(ttyout,
>Release-Note:
>Audit-Trail:
>Unformatted: