| Summary: | FTP does not fully parse ftp:// URLs | ||
|---|---|---|---|
| Product: | Base System | Reporter: | kientzle |
| Component: | misc | Assignee: | Ceri Davies <ceri> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 3.3-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
kientzle
2000-02-23 18:40:01 UTC
<<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 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 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. State Changed From-To: feedback->closed Feedback timeout (6 months or more). I will handle any feedback that this closure generates. Responsible Changed From-To: freebsd-bugs->ceri Feedback timeout (6 months or more). I will handle any feedback that this closure generates. |