aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorYoshinobu Inoue <shin@FreeBSD.org>2000-02-12 15:03:05 +0000
committerYoshinobu Inoue <shin@FreeBSD.org>2000-02-12 15:03:05 +0000
commit2bd54ee847410e8acfe5a6e34cbf319f55023957 (patch)
tree220d1fe81018e6d1db4976cc43733bff5ec46ca9 /usr.bin
parenteb06360f04a96fb0010bd0b774f305693bc2040d (diff)
downloadsrc-2bd54ee847410e8acfe5a6e34cbf319f55023957.tar.gz
src-2bd54ee847410e8acfe5a6e34cbf319f55023957.zip
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
Notes
Notes: svn path=/head/; revision=57165
Diffstat (limited to 'usr.bin')
-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 62b64e9e35dd..fa6a0e44ba18 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 e2c6a39ad456..86dc44dec645 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 aeb74878c8a7..5a1e5e626ed4 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);