Permalink
Browse files

Quick fix for argument check problem with IPv6 addresses

The code verifying that a hostname argument is passed on the command
line only checked for IPv4 addresses, but not IPv6 addresses. This
caused the command "netcat -6 ::1 22" to fail with a "missing hostname
argument" error.
  • Loading branch information...
veithen committed Dec 30, 2013
1 parent 35954b5 commit c8c0234eec9299bada840305776b81fe7d1e41d9
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/netcat.c
View
@@ -574,7 +574,12 @@ int main(int argc, char *argv[])
netcat_mode = NETCAT_CONNECT;
/* first check that a host parameter was given */
- if (!remote_host.host.iaddrs[0].s_addr) {
+ // TODO: find a more elegant way to check the IPv6 address
+ if (!remote_host.host.iaddrs[0].s_addr &&
+ !remote_host.host6.iaddrs[0].__in6_u.__u6_addr32[0] &&
+ !remote_host.host6.iaddrs[0].__in6_u.__u6_addr32[1] &&
+ !remote_host.host6.iaddrs[0].__in6_u.__u6_addr32[2] &&
+ !remote_host.host6.iaddrs[0].__in6_u.__u6_addr32[3]) {
/* FIXME: The Networking specifications state that host address "0" is a
valid host to connect to but this broken check will assume as not
specified. */

0 comments on commit c8c0234

Please sign in to comment.