Skip to content

Commit

Permalink
Fix -4 option when IPv6 disabled
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pbhenson authored Jul 28, 2019
1 parent 12961d5 commit 509f5a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,13 @@ int main(int argc, char** argv)
while ((c = optparse_long(&optparse_state, longopts, NULL)) != EOF) {
switch (c) {
case '4':
#ifdef IPV6
if (hints_ai_family != AF_UNSPEC) {
fprintf(stderr, "%s: can't specify both -4 and -6\n", prog);
exit(1);
}
hints_ai_family = AF_INET;
#endif
break;
case '6':
#ifdef IPV6
Expand Down

0 comments on commit 509f5a5

Please sign in to comment.