summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/fetch.c
diff options
context:
space:
mode:
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