summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2017-03-24 14:26:01 +0000
committerdes <des@FreeBSD.org>2017-03-24 14:26:01 +0000
commitbb1be6c053d51686918f67daf4818da800b24687 (patch)
tree1e503dd3feaf102dfb289d919f0ec472b21b5a91 /lib/libfetch/fetch.c
parentee4124b33f70470844978d1c8e4cd6ae062ebb0a (diff)
downloadFreeBSD-src-bb1be6c053d51686918f67daf4818da800b24687.zip
FreeBSD-src-bb1be6c053d51686918f67daf4818da800b24687.tar.gz
MFH (r313974,r314596): open .netrc early in case we want to drop privs
MFH (r314396,r315143): fix a crash caused by an incorrect format string MFH (r314701): fix handling of 416 errors when requesting a range MFH (r315455): fix parsing of IP literals (square brackets) PR: 212065, 217723
Diffstat (limited to 'lib/libfetch/fetch.c')
-rw-r--r--lib/libfetch/fetch.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 8d92bbc..f251083 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -284,6 +284,7 @@ fetchMakeURL(const char *scheme, const char *host, int port, const char *doc,
seturl(pwd);
#undef seturl
u->port = port;
+ u->netrcfd = -2;
return (u);
}
@@ -349,6 +350,7 @@ fetchParseURL(const char *URL)
fetch_syserr();
return (NULL);
}
+ u->netrcfd = -2;
/* scheme name */
if ((p = strstr(URL, ":/"))) {
@@ -384,18 +386,17 @@ fetchParseURL(const char *URL)
}
/* hostname */
-#ifdef INET6
if (*p == '[' && (q = strchr(p + 1, ']')) != NULL &&
(*++q == '\0' || *q == '/' || *q == ':')) {
- if ((i = q - p - 2) > MAXHOSTNAMELEN)
+ if ((i = q - p) > MAXHOSTNAMELEN)
i = MAXHOSTNAMELEN;
- strncpy(u->host, ++p, i);
+ strncpy(u->host, p, i);
p = q;
- } else
-#endif
+ } else {
for (i = 0; *p && (*p != '/') && (*p != ':'); p++)
if (i < MAXHOSTNAMELEN)
u->host[i++] = *p;
+ }
/* port */
if (*p == ':') {
@@ -442,12 +443,12 @@ nohost:
}
DEBUG(fprintf(stderr,
- "scheme: [%s]\n"
- "user: [%s]\n"
- "password: [%s]\n"
- "host: [%s]\n"
- "port: [%d]\n"
- "document: [%s]\n",
+ "scheme: \"%s\"\n"
+ "user: \"%s\"\n"
+ "password: \"%s\"\n"
+ "host: \"%s\"\n"
+ "port: \"%d\"\n"
+ "document: \"%s\"\n",
u->scheme, u->user, u->pwd,
u->host, u->port, u->doc));
OpenPOWER on IntegriCloud