diff options
author | Yoshinobu Inoue <shin@FreeBSD.org> | 1999-12-28 05:37:39 +0000 |
---|---|---|
committer | Yoshinobu Inoue <shin@FreeBSD.org> | 1999-12-28 05:37:39 +0000 |
commit | 9b59fde4e0c287dde4ddb2f4f34f4b0a58dacbf9 (patch) | |
tree | aa31366c35d453783e0dbf9fffbed908be3f0fad /sbin/ping6 | |
parent | 0e17bca17c7b9244ca74b3ea91f6b2ea7376e38a (diff) | |
download | src-9b59fde4e0c287dde4ddb2f4f34f4b0a58dacbf9.tar.gz src-9b59fde4e0c287dde4ddb2f4f34f4b0a58dacbf9.zip |
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.
Notes
Notes:
svn path=/head/; revision=55167
Diffstat (limited to 'sbin/ping6')
-rw-r--r-- | sbin/ping6/ping6.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index d1186559400c..34de2bdc00b4 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"); |