Fix -4 option when IPv6 disabled

When IPv6 is disabled, hints_ai_family is set to AF_INET at initialization, resulting in the error "can't specify both -4 and -6" if the -4 option is supplied. If there's no IPv6, make the -4 option a no-op.
pull/154/head
Paul B. Henson 5 years ago committed by GitHub
parent 12961d59ec
commit 509f5a59cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -427,11 +427,13 @@ int main(int argc, char** argv)
while ((c = optparse_long(&optparse_state, longopts, NULL)) != EOF) { while ((c = optparse_long(&optparse_state, longopts, NULL)) != EOF) {
switch (c) { switch (c) {
case '4': case '4':
#ifdef IPV6
if (hints_ai_family != AF_UNSPEC) { if (hints_ai_family != AF_UNSPEC) {
fprintf(stderr, "%s: can't specify both -4 and -6\n", prog); fprintf(stderr, "%s: can't specify both -4 and -6\n", prog);
exit(1); exit(1);
} }
hints_ai_family = AF_INET; hints_ai_family = AF_INET;
#endif
break; break;
case '6': case '6':
#ifdef IPV6 #ifdef IPV6

Loading…
Cancel
Save