summaryrefslogtreecommitdiffstats
path: root/sbin/ping6/ping6.c
diff options
context:
space:
mode:
authorshin <shin@FreeBSD.org>1999-12-28 05:37:39 +0000
committershin <shin@FreeBSD.org>1999-12-28 05:37:39 +0000
commit21448b46272429cd4260638c31ec239118e6fb02 (patch)
tree3761183d74afd9038bbe0f1e1a64339ed76d2fcc /sbin/ping6/ping6.c
parent8b8214b6d3bce6e64a982ab67d5d17dfa3f85b0b (diff)
downloadFreeBSD-src-21448b46272429cd4260638c31ec239118e6fb02.zip
FreeBSD-src-21448b46272429cd4260638c31ec239118e6fb02.tar.gz
Small bug fix and improvements
(1)added error check of if_nameindex() return value at getaddrinfo(). (2)print out more detailed information when getaddrinfo() error value is EAI_SYSTEM.(in this case system error num is kept in errno) (1) is Discovered by: jinmei@kame.net in KAME environment.
Diffstat (limited to 'sbin/ping6/ping6.c')
-rw-r--r--sbin/ping6/ping6.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index d118655..34de2bd 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -434,6 +434,8 @@ main(argc, argv)
ret_ga = getaddrinfo(target, NULL, &hints, &res);
if (ret_ga) {
fprintf(stderr, "ping6: %s\n", gai_strerror(ret_ga));
+ if (ret_ga == EAI_SYSTEM)
+ errx(1, "%s", strerror(errno));
exit(1);
}
if (res->ai_canonname)
@@ -586,8 +588,12 @@ main(argc, argv)
for (hops = 0; hops < argc - 1; hops++) {
struct addrinfo *iaip;
- if ((error = getaddrinfo(argv[hops], NULL, &hints, &iaip)))
- errx(1, gai_strerror(error));
+ if ((error = getaddrinfo(argv[hops], NULL, &hints, &iaip))) {
+ fprintf(stderr, "ping6: %s\n", gai_strerror(error));
+ if (error == EAI_SYSTEM)
+ errx(1, strerror(errno));
+ exit(1);
+ }
if (SIN6(res->ai_addr)->sin6_family != AF_INET6)
errx(1,
"bad addr family of an intermediate addr");
OpenPOWER on IntegriCloud