NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/58834: whois(1) spuriously fails with exit status 65=EHOSTUNREACH on v4-only hosts
>Number: 58834
>Category: bin
>Synopsis: whois(1) spuriously fails with exit status 65=EHOSTUNREACH on v4-only hosts
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 19 22:10:00 +0000 2024
>Originator: Taylor R Campbell
>Release: current, 10, 9, ...
>Organization:
The NetBSDv6 Whoisdation
>Environment:
>Description:
On certain inputs, when run on hosts without IPv6 connectivity, whois(1) will successfully query WHOIS information, print it to stdout, and then exit with status 65=EHOSTUNREACH instead of status 0 as expected.
Example:
$ whois 4.2.2.1 >/dev/null; echo $?
65
This happens because the variable `error', which is used to record the last errno value in a loop over getaddrinfo(3) results in the event that they all fail in order to print an error message, is reused for recursive whois results and the final return value later on:
199 for (s = -1, ai = res; ai != NULL; ai = ai->ai_next) {
200 s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
201 if (s < 0) {
202 error = errno;
203 reason = "socket";
204 continue;
205 }
...
214 }
215 freeaddrinfo(res);
216 if (s < 0) {
217 if (reason) {
218 errno = error;
219 warn("%s: %s", server, reason);
220 } else
221 warnx("Unknown error in connection attempt");
222 return (1);
223 }
... /* NOTE: error is not reset to zero here */
284 if (nhost != NULL) {
285 error = whois(query, nhost, port, 0);
286 free(nhost);
287 }
288
289 return (error);
https://nxr.netbsd.org/xref/src/usr.bin/whois/whois.c?r=1.38#199
>How-To-Repeat:
1. set up a host with no IPv6 connectivity but DNS answers that have AAAA records for WHOIS servers
2. run a whois(1) with an input whose WHOIS server has AAAA records, e.g. an IP address for which whois.arin.net will be queried
3. examine the process's exit status
>Fix:
reset local variable `error' to zero at line 224 in whois.c rev. 1.38
Home |
Main Index |
Thread Index |
Old Index