diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-03-10 06:20:11 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-03-10 06:20:11 +0000 |
commit | 8f8a7f23e00e843d1b1998d5fc8dbdc21b5e9114 (patch) | |
tree | 395cfd4925be9329e1ddce35ba195681ff748f59 /usr.bin | |
parent | ce21e2204c94a5e821df977950311d9ee757d600 (diff) |
correct use of getnameinfo. PR 3138
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ftp/fetch.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index c56d972e69c..e7e805c2b3f 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.43 2003/02/17 18:51:11 millert Exp $ */ +/* $OpenBSD: fetch.c,v 1.44 2003/03/10 06:20:10 itojun Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fetch.c,v 1.43 2003/02/17 18:51:11 millert Exp $"; +static char rcsid[] = "$OpenBSD: fetch.c,v 1.44 2003/03/10 06:20:10 itojun Exp $"; #endif /* not lint */ /* @@ -107,7 +107,7 @@ url_get(origline, proxyenv, outfile) volatile int s, out; size_t len; char *cp, *ep, *portnum, *path; - char pbuf[NI_MAXSERV]; + char pbuf[NI_MAXSERV], hbuf[NI_MAXHOST]; const char * volatile savefile; char *line, *host, *port, *buf; char * volatile proxy; @@ -309,10 +309,11 @@ url_get(origline, proxyenv, outfile) s = -1; for (res = res0; res; res = res->ai_next) { - getnameinfo(res->ai_addr, res->ai_addrlen, pbuf, sizeof(pbuf), - 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)); if (verbose) - fprintf(ttyout, "Trying %s...\n", pbuf); + fprintf(ttyout, "Trying %s...\n", hbuf); s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (s == -1) { |