summaryrefslogtreecommitdiff
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-03-11 04:01:12 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-03-11 04:01:12 +0000
commit7de737cff3583b27b0fa95b0e13da96a6eeaf909 (patch)
tree38e82b3d349515b273d6d9b4d9cd2071c38db653 /usr.bin/ftp
parente15bba03dc747f171e264072a2305d7a7b9c5c99 (diff)
check error on getnameinfo failure.
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/ftp.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index 60bdb186ea1..26cd2e92c99 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp.c,v 1.49 2002/07/04 10:08:00 jakob Exp $ */
+/* $OpenBSD: ftp.c,v 1.50 2003/03/11 04:01:11 itojun Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
@@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$OpenBSD: ftp.c,v 1.49 2002/07/04 10:08:00 jakob Exp $";
+static char rcsid[] = "$OpenBSD: ftp.c,v 1.50 2003/03/11 04:01:11 itojun Exp $";
#endif
#endif /* not lint */
@@ -183,8 +183,9 @@ hookup(host, port)
if (res0->ai_next) /* if we have multiple possibilities */
#endif
{
- getnameinfo(res->ai_addr, res->ai_addrlen,
- hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
+ if (getnameinfo(res->ai_addr, res->ai_addrlen,
+ hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0)
+ strlcpy(hbuf, "unknown", sizeof(hbuf));
fprintf(ttyout, "Trying %s...\n", hbuf);
}
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -199,9 +200,11 @@ hookup(host, port)
if (error) {
/* this "if" clause is to prevent print warning twice */
if (res->ai_next) {
- getnameinfo(res->ai_addr, res->ai_addrlen,
- hbuf, sizeof(hbuf), NULL, 0,
- NI_NUMERICHOST);
+ if (getnameinfo(res->ai_addr, res->ai_addrlen,
+ hbuf, sizeof(hbuf), NULL, 0,
+ NI_NUMERICHOST) != 0)
+ strlcpy(hbuf, "(unknown)",
+ sizeof(hbuf));
warn("connect to address %s", hbuf);
}
cause = "connect";