summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2020-02-22 00:58:29 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2020-02-22 00:58:29 +0000
commit58ad709a830b02002faaba32eb8caaba9e9541b7 (patch)
treeb4e88093f63e2429b13a7c76843c2164b19d96b8 /usr.bin
parent4d8599785ede8219e1a311a114ce99310ef808e2 (diff)
Respect userinfo even when built with NOSSL (floppy ramdisks)
Not handling it is incorrect and can lead to credentials leaks in DNS requests. The resulting growth is reasonable (about 300 bytes on amd64). ok yasuoka@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ftp/fetch.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index 6d200cfd219..57c237a50e3 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.192 2020/02/20 00:45:09 yasuoka Exp $ */
+/* $OpenBSD: fetch.c,v 1.193 2020/02/22 00:58:28 jca Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -326,7 +326,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile, int las
char *proxyhost = NULL;
#ifndef NOSSL
char *sslpath = NULL, *sslhost = NULL;
- int ishttpurl = 0, ishttpsurl = 0;
+ int ishttpsurl = 0;
#endif /* !NOSSL */
#ifndef SMALL
char *full_host = NULL;
@@ -347,9 +347,6 @@ url_get(const char *origline, const char *proxyenv, const char *outfile, int las
errx(1, "Can't allocate memory to parse URL");
if (strncasecmp(newline, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
host = newline + sizeof(HTTP_URL) - 1;
-#ifndef NOSSL
- ishttpurl = 1;
-#endif /* !NOSSL */
#ifndef SMALL
scheme = HTTP_URL;
#endif /* !SMALL */
@@ -374,13 +371,12 @@ url_get(const char *origline, const char *proxyenv, const char *outfile, int las
path = strchr(host, '/'); /* Find path */
-#ifndef NOSSL
/*
* Look for auth header in host.
* Basic auth from RFC 2617, valid characters for path are in
* RFC 3986 section 3.3.
*/
- if (ishttpurl || ishttpsurl) {
+ if (!isftpurl) {
p = strchr(host, '@');
if (p != NULL && (path == NULL || p < path)) {
*p++ = '\0';
@@ -391,7 +387,6 @@ url_get(const char *origline, const char *proxyenv, const char *outfile, int las
path = strchr(host, '/');
}
}
-#endif /* !NOSSL */
if (EMPTYSTRING(path)) {
if (outfile) { /* No slash, but */
@@ -735,7 +730,6 @@ noslash:
restart_point = 0;
}
#endif /* SMALL */
-#ifndef NOSSL
if (credentials) {
ftp_printf(fin,
"GET /%s HTTP/1.1\r\n"
@@ -745,7 +739,6 @@ noslash:
free(credentials);
credentials = NULL;
} else
-#endif /* NOSSL */
ftp_printf(fin,
"GET /%s HTTP/1.1\r\n"
"Connection: close\r\n"