aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/ftp/fetch.c
diff options
context:
space:
mode:
authorYoshinobu Inoue <shin@FreeBSD.org>2000-02-12 15:16:59 +0000
committerYoshinobu Inoue <shin@FreeBSD.org>2000-02-12 15:16:59 +0000
commit319c8e321c8ecb62b51f1f08b2a73cddb0d89693 (patch)
tree0d0726a9c7d8968a98299f66717dd772b4691939 /usr.bin/ftp/fetch.c
parent2bd54ee847410e8acfe5a6e34cbf319f55023957 (diff)
downloadsrc-319c8e321c8ecb62b51f1f08b2a73cddb0d89693.tar.gz
src-319c8e321c8ecb62b51f1f08b2a73cddb0d89693.zip
Fix parsing problems.
-"ftp hostname:/path" was not working. - IPv6 raw addr specification was not well supported, such as, "ftp http://\[1:2:3:4:5:6:7:8:\]/index.html" Approved by: jkh
Notes
Notes: svn path=/head/; revision=57166
Diffstat (limited to 'usr.bin/ftp/fetch.c')
-rw-r--r--usr.bin/ftp/fetch.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index fa6a0e44ba18..a494e7ef2fad 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -527,7 +527,16 @@ bad_ftp_url:
if (portnum != NULL)
*portnum++ = '\0';
} else { /* classic style `host:file' */
- dir = strchr(host, ':');
+ char *end_brace;
+
+ if (*host == '[' &&
+ (end_brace = strrchr(host, ']')) != NULL) {
+ /*IPv6 addr in []*/
+ host++;
+ *end_brace = '\0';
+ dir = strchr(end_brace + 1, ':');
+ } else
+ dir = strchr(host, ':');
}
parsed_url:
if (EMPTYSTRING(host)) {
@@ -665,9 +674,19 @@ int
isurl(p)
const char *p;
{
+ char *path, pton_buf[16];
+
if (strncasecmp(p, FTP_URL, sizeof(FTP_URL) - 1) == 0
|| strncasecmp(p, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
return 1;
}
+ if (*p == '[' && (path = strrchr(p, ']')) != NULL) /*IPv6 addr in []*/
+ return (*(++path) == ':') ? 1 : 0;
+#ifdef INET6
+ if (inet_pton(AF_INET6, p, pton_buf) == 1) /* raw IPv6 addr */
+ return 0;
+#endif
+ if (strchr(p, ':') != NULL) /* else, if ':' exist */
+ return 1;
return 0;
}