summaryrefslogtreecommitdiffstats
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorshin <shin@FreeBSD.org>2000-02-12 15:03:05 +0000
committershin <shin@FreeBSD.org>2000-02-12 15:03:05 +0000
commit4b6c4ae8e8703a11a3fd8ec1108949150418c676 (patch)
tree6c16a93f2dcd21d3d8eebb02a843268d843a7d75 /usr.bin/ftp
parent69be10ec73f0a4dc04c4b0849b59b6ba11e039ff (diff)
downloadFreeBSD-src-4b6c4ae8e8703a11a3fd8ec1108949150418c676.zip
FreeBSD-src-4b6c4ae8e8703a11a3fd8ec1108949150418c676.tar.gz
Fix several bogus bugs
-Some address resolving related structures were not freed after use. -Some error messages were not printed out correctly. Approved by: jkh
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/fetch.c9
-rw-r--r--usr.bin/ftp/ftp.c1
-rw-r--r--usr.bin/ftp/main.c5
3 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index 62b64e9..fa6a0e4 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -98,7 +98,7 @@ url_get(origline, proxyenv)
const char *proxyenv;
{
struct addrinfo hints;
- struct addrinfo *res;
+ struct addrinfo *res0, *res;
char nameinfo[2 * INET6_ADDRSTRLEN + 1];
int i, out, isftpurl;
char *port;
@@ -207,9 +207,10 @@ url_get(origline, proxyenv)
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(host, port, &hints, &res);
+ res0 = res;
if (error) {
warnx("%s: %s", host, gai_strerror(error));
- if (error = EAI_SYSTEM)
+ if (error == EAI_SYSTEM)
warnx("%s: %s", host, strerror(errno));
goto cleanup_url_get;
}
@@ -238,11 +239,13 @@ url_get(origline, proxyenv)
res = res->ai_next;
if (res)
continue;
+ warn("Can't connect to %s", host);
goto cleanup_url_get;
}
break;
}
+ freeaddrinfo(res0);
/*
* Construct and send the request. We're expecting a return
@@ -394,6 +397,8 @@ cleanup_url_get:
if (proxy)
free(proxy);
free(line);
+ if (res0 != NULL)
+ freeaddrinfo(res0);
return (-1);
}
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index e2c6a39..86dc44d 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -166,6 +166,7 @@ hookup(host, port)
goto bad;
}
memcpy(&hisctladdr, res->ai_addr, res->ai_addrlen);
+ freeaddrinfo(res0);
len = sizeof(myctladdr);
if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) {
warn("getsockname");
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index aeb7487..5a1e5e6 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -232,10 +232,9 @@ main(argc, argv)
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(src_addr, NULL, &hints, &res);
if (error) {
- fprintf(stderr, "%s: %s", src_addr,
- gai_strerror(error));
+ warnx("%s: %s", src_addr, gai_strerror(error));
if (error == EAI_SYSTEM)
- errx(1, "%s", strerror(errno));
+ warnx("%s", strerror(errno));
exit(1);
}
memcpy(&bindto, res->ai_addr, res->ai_addrlen);
OpenPOWER on IntegriCloud