On Tue, 10 Jul 2001, I wrote:
> On Tue, 10 Jul 2001, Sheldon Hearn wrote:
>
> > If I replace the bind(2) call in daemon.c with the following:
> >
> > if (bind(listen_sockets[sk], (struct sockaddr *)&sin,
> > ipv6_address ? sizeof(sin.v6) : sizeof(sin.v4)) < 0)
> >
> Sounds very plausible. In fact, I think the previous code was plain
> wrong. Interestingly, the equivalent change has already been made in the
> Exim 4 source tree, where there has been some general re-arrangement of
> the code. I've put this patch into the Exim 3 source tree, so that if
> (when!) there is another release, it will be there. And I've made a
> patch file, in case anybody wants it.
OHO! When I came to run my comprehensive tests (for a different problem)
I discovered that your patch is wrong, Sheldon. Sorry. The correct code
is in fact
if (bind(listen_sockets[sk], (struct sockaddr *)&sin,
#ifdef HAVE_IPV6
ipv6_socket? sizeof(sin.v6) : sizeof(sin.v4)
#else
sizeof(sin)
#endif
) < 0)
Two changes: (1) The test should be on ipv6_socket, not on ipv6_address;
(2) When compiled without HAVE_IPV6, you have to revert to sizeof(sin)
because sin.v4 won't exist.
(1) broke things when I tried running this on Solaris 8. Even though it
was an IPv4 address I was using, it wanted the correct length for an
IPv6 socket.
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.