Nmap Development mailing list archives
Re: Ncat: socket bind error on Mac OS X
From: David Fifield <david () bamsoftware com>
Date: Sun, 27 Jul 2008 16:10:05 -0600
On Sun, Jul 27, 2008 at 01:14:40PM +0200, Dirk Loss wrote:
on Mac OS X 10.5.4 (Intel) Ncat dies with the following error when I try to put it into listening mode: $ ncat -l 22222 bind: Invalid argument Running Ncat as root, switching to UDP or disabling IPv6 in my system preferences did not help. I verified that there is no other process listing on my local TCP port 22222. Apparently the bind() call in sys_wrap.c returns -1 and errno = 22 (EINVAL). According to the man page [1], this means that either the "socket is already bound to an address and the protocol does not support binding to a new address" or the "socket may have been shut down."
I think I have tracked this down. bind is being picky about the address length. Currently do_listen is calling Bind with sizeof(srcaddr), which is 128. If I change it to sizeof(struct sockaddr_in), which is 16, then it works. Of course, that only works for IPv4 addresses, so it needs to be based on the address family. BSDs have an extra sockaddr.sa_len (and sockaddr_storage.ss_len, and sockaddr_in.sin_len) member. Currently it's always set to 0 by memset. I tried setting it to a proper value and it didn't seem to make a difference. However, changing the address length passed to bind did work. David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Ncat: socket bind error on Mac OS X Dirk Loss (Jul 27)
- Re: Ncat: socket bind error on Mac OS X Kris Katterjohn (Jul 27)
- Re: Ncat: socket bind error on Mac OS X David Fifield (Jul 27)
- Re: Ncat: socket bind error on Mac OS X Kris Katterjohn (Jul 27)
- Re: Ncat: socket bind error on Mac OS X David Fifield (Jul 27)
- Re: Ncat: socket bind error on Mac OS X Dirk Loss (Jul 27)
- Re: Ncat: socket bind error on Mac OS X Kris Katterjohn (Jul 27)