Subject: bin/3520: URL parsing failure in ftp
To: None <>
From: Havard Eidnes <>
List: netbsd-bugs
Date: 04/21/1997 18:51:33
>Number:         3520
>Category:       bin
>Synopsis:       URL parsing in ftp using ftp://host/dir/file fails
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 21 10:05:01 1997
>Originator:     Havard Eidnes
>Release:        NetBSD-current April 20 1997
System: NetBSD 1.2D NetBSD 1.2D (VADER) #0: Mon Apr 14 23:27:38 MEST 1997 i386

	URL parsing in fetch.c in ftp misparses an URL of the form
	ftp://host/dir/file, resulting in "host" being used as the user
	name, which leads to failure.


% ftp -d
user host port (null) dir pathchar file
Connected to
220 FTP server ready.
---> SYST
215 UNIX Type: L8
Remote system type is UNIX.
Using binary mode to transfer files.
---> USER
530 Sorry, I can't accept a cleartext password over the wire.
ftp: Login failed.
ftp: Can't connect or login to host `'
---> QUIT
221 Goodbye.

	See above.
	No fix here, sorry, but the part starting at line 432 of fetch.c
	looks suspect:

                                /* look for [user:pass@]host[:port] */
                        user = host;
                        pass = strpbrk(user, ":@/");
                        if (pass == NULL || *pass == '/')
                                goto parsed_url;

	Why is "user" set to "host", and more importantly, why is it not
	reset if no user name was found in the URL?