IPv6 and FreeBSD
Johan van Selst
johans at stack.nl
Tue Oct 21 16:41:04 UTC 2008
Julien ÉLIE wrote:
>> # sudo -u news nnrpd -D -p 563 -S
>> nnrpd: can't bind (Invalid argument)
EINVAL is returned if the addrlen argument to bind is wrong.
Looking at the source of nnrpd.c (INN 2.4.3 that is), it seems that
if the -b option is missing, ListenAddress will never be initialized(!)
The 'ssa' address storage variable is then first used to store an IPv6
address (with inet_pton - this fails) and then an IPv4 address
(INADDR_ANY). The socket is then bound with:
bind(lfd, (struct sockaddr *) &ssa, sizeof(ssa))
In this call ssa points to a sockaddr_storage variable, which means the
wrong third argument is passed for an IPv4 address (since ssa now has
the correct size for storing an IPv6 address).
The third argument to bind() should be sizeof(struct sockaddr_in) when
an IPv4 address is stored in 'ssa' and sizeof(struct sockaddr_in6) when
an IPv6 address is used.
This problem is not really OS-dependant, but I guess Linux doesn't care
if the specified size is larger than what it expected.
Regards,
Johan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20081021/a79f5b7a/attachment.bin>
More information about the inn-workers
mailing list