From nobody@FreeBSD.org  Wed Feb 23 10:33:49 2000
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21])
	by hub.freebsd.org (Postfix) with ESMTP id 858DF37B97C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 23 Feb 2000 10:33:49 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.9.3/8.9.2) id KAA01585;
	Wed, 23 Feb 2000 10:33:49 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Message-Id: <200002231833.KAA01585@freefall.freebsd.org>
Date: Wed, 23 Feb 2000 10:33:49 -0800 (PST)
From: kientzle@acm.org
Sender: nobody@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: FTP does not fully parse ftp:// URLs
X-Send-Pr-Version: www-1.0

>Number:         16938
>Category:       misc
>Synopsis:       FTP does not fully parse ftp:// URLs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ceri
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 23 10:40:01 PST 2000
>Closed-Date:    Sun Jun 08 11:00:48 PDT 2003
>Last-Modified:  Sun Jun 08 11:00:48 PDT 2003
>Originator:     Tim Kientzle
>Release:        3.3-RELEASE
>Organization:
>Environment:
FreeBSD clover.kientzle.com 3.3-RELEASE FreeBSD 3.3-RELEASE #4: Sun Jan  2 11:38:58 PST 2000     root@clover.kientzle.com:/usr/src/sys/compile/CLOVER  i386
>Description:
FTP does not decode %XX escapes occuring within
username or password portions of ftp: URLs as specified
in RFC 1738.  These escapes are necessary if the username or
password contains a :, @, or / character.

Example: to represent a password of 'p@ssword', you must write
ftp://user:p%40ssword@host.domain.com/

FYI, fetch and ncftpget both handle this correctly.


>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: kientzle@acm.org
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: misc/16938: FTP does not fully parse ftp:// URLs
Date: Wed, 23 Feb 2000 13:51:52 -0500 (EST)

 <<On Wed, 23 Feb 2000 10:33:49 -0800 (PST), kientzle@acm.org said:
 
 >> Synopsis:       FTP does not fully parse ftp:// URLs
 
 The fact that ftp(1) knows anything at all about URIs is a bug
 (imported from another *BSD).
 
 -GAWollman
 
 --
 Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
 wollman@lcs.mit.edu  | O Siem / The fires of freedom 
 Opinions not those of| Dance in the burning flame
 MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
 

From: Pierre-Paul Lavoie <ppl@nbnet.nb.ca>
To: freebsd-gnats-submit@FreeBSD.org, kientzle@acm.org
Cc:  
Subject: Re: misc/16938: FTP does not fully parse ftp:// URLs
Date: Mon, 31 Dec 2001 01:25:17 -0400

 here a patch that worked for me:
 
 
 --- fetch.c	Mon Dec 31 01:05:01 2001
 +++ /fetch-patch.c	Mon Dec 31 01:04:51 2001
 @@ -88,6 +88,33 @@
  jmp_buf	httpabort;
  
  /*
 + * Decode the %XX escapes in the string.
 + * return -1 on failure, 0 on success
 + */
 +static int
 +url_decode(str)
 +	char *str;
 +{
 +	char v[3] = "XX";
 +	char *vp;
 +
 +	if (str == NULL)
 +		return 0;
 +
 +	while ( (str = strchr(str, '%')) != NULL)
 +	{
 +		if (isxdigit(*(str+1)) == 0 || isxdigit(*(str+2)) == 0)
 +			return -1;
 +
 +		v[0] = *(str+1);
 +		v[1] = *(str+2);
 +		*str = (char)strtol(v, &vp, 16);
 +		memmove(str+1, str+3, strlen(str+3) + 1);
 +	}
 +	return 0;
 +}
 +
 +/*
   * Retrieve URL, via the proxy in $proxyvar if necessary.
   * Modifies the string argument given.
   * Returns -1 on failure, 0 on success
 @@ -160,6 +187,12 @@
  		goto cleanup_url_get;
  	}
  
 +	if (url_decode(path) == -1 || url_decode(savefile) == -1)
 +	{
 +		warnx("Invalid URL (invalid encoding): %s", origline);
 +		goto cleanup_url_get;
 +	}
 +
  	if (proxyenv != NULL) {				/* use proxy */
  		proxy = strdup(proxyenv);
  		if (proxy == NULL)
 @@ -589,6 +622,10 @@
  				dir = NULL;
  			}
  		}
 +		if (url_decode(user) == -1 || url_decode(pass) == -1 || 
 +							url_decode(dir) == -1 || url_decode(file) == -1)
 +			goto bad_ftp_url;
 +
  		if (debug)
  			printf("user %s:%s host %s port %s dir %s file %s\n",
  			    user, pass, host, portnum, dir, file);
State-Changed-From-To: open->feedback 
State-Changed-By: johan 
State-Changed-When: Thu Aug 22 11:11:59 PDT 2002 
State-Changed-Why:  
Is this still a problem in more recent version of 
FreeBSD, say 4.6-RELEASE? 

Please followup by sending a mail to 
freebsd-gnats-submit@FreeBSD.org 
with the subject of this mail intact. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=16938 
State-Changed-From-To: feedback->closed 
State-Changed-By: ceri 
State-Changed-When: Sun Jun 8 11:00:46 PDT 2003 
State-Changed-Why:  
Feedback timeout (6 months or more). 
I will handle any feedback that this closure generates. 


Responsible-Changed-From-To: freebsd-bugs->ceri 
Responsible-Changed-By: ceri 
Responsible-Changed-When: Sun Jun 8 11:00:46 PDT 2003 
Responsible-Changed-Why:  
Feedback timeout (6 months or more). 
I will handle any feedback that this closure generates. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=16938 
>Unformatted:
