Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp When given an URL that contains "://" but is not...
details: https://anonhg.NetBSD.org/src/rev/a03d9a078e23
branches: trunk
changeset: 777598:a03d9a078e23
user: apb <apb%NetBSD.org@localhost>
date: Fri Feb 24 19:40:49 2012 +0000
description:
When given an URL that contains "://" but is not recognised,
print an error message. Now "ftp https://foo/bar" prints
ftp: Unsupported URL scheme `https'
instead of
ftp: Can't lookup `https:ftp': No address associated with hostname
ftp: Can't connect or login to host `https:?'
diffstat:
usr.bin/ftp/fetch.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diffs (54 lines):
diff -r 903dafbb6a32 -r a03d9a078e23 usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c Fri Feb 24 18:45:20 2012 +0000
+++ b/usr.bin/ftp/fetch.c Fri Feb 24 19:40:49 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fetch.c,v 1.195 2011/12/10 05:53:58 lukem Exp $ */
+/* $NetBSD: fetch.c,v 1.196 2012/02/24 19:40:49 apb Exp $ */
/*-
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.195 2011/12/10 05:53:58 lukem Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.196 2012/02/24 19:40:49 apb Exp $");
#endif /* not lint */
/*
@@ -700,7 +700,7 @@
hints.ai_protocol = 0;
error = getaddrinfo(host, port, &hints, &res0);
if (error) {
- warnx("Can't lookup `%s:%s': %s", host, port,
+ warnx("Can't LOOKUP `%s:%s': %s", host, port,
(error == EAI_SYSTEM) ? strerror(errno)
: gai_strerror(error));
goto cleanup_fetch_url;
@@ -1687,6 +1687,7 @@
go_fetch(const char *url)
{
char *proxyenv;
+ char *p;
#ifndef NO_ABOUT
/*
@@ -1731,6 +1732,18 @@
return (fetch_url(url, NULL, NULL, NULL));
/*
+ * If it contains "://" but does not begin with ftp://
+ * or something that was already handled, then it's
+ * unsupported.
+ *
+ * If it contains ":" but not "://" then we assume the
+ * part before the colon is a host name, not an URL scheme,
+ * so we don't try to match that here.
+ */
+ if ((p = strstr(url, "://")) != NULL && ! STRNEQUAL(url, FTP_URL))
+ errx(1, "Unsupported URL scheme `%.*s'", (p - url), url);
+
+ /*
* Try FTP URL-style and host:file arguments next.
* If ftpproxy is set with an FTP URL, use fetch_url()
* Othewise, use fetch_ftp().
Home |
Main Index |
Thread Index |
Old Index