inspircd

A modular C++ IRC daemon (ircd). https://www.inspircd.org/
Log | Files | Refs | README

commit b4599531f97a9e6207b6bb8d728d7523b6995523
parent c13d0744fee3b1411d238d45ad66eef8b104f72e
Author: Peter Powell <petpow@saberuk.com>
Date:   Thu, 25 Apr 2019 19:20:07 +0100

Fix broken linking over IPv4 on IPv6 capable systems.

If no bind address was specified then one would be
created which had an incompatible address family to
the address that the server was trying to connect to.

Diffstat:
Msrc/modules/m_spanningtree/treesocket1.cpp | 20+++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp @@ -47,12 +47,22 @@ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const irc::sockets::sockad irc::sockets::sockaddrs bind; memset(&bind, 0, sizeof(bind)); - if ((dest.family() == AF_INET || dest.family() == AF_INET6) && !irc::sockets::aptosa(link->Bind, 0, bind)) + if (!link->Bind.empty() && (dest.family() == AF_INET || dest.family() == AF_INET6)) { - state = I_ERROR; - SetError("Bind address '" + link->Bind + "' is not an valid IPv4 or IPv6 address"); - TreeSocket::OnError(I_ERR_BIND); - return; + if (!irc::sockets::aptosa(link->Bind, 0, bind)) + { + state = I_ERROR; + SetError("Bind address '" + link->Bind + "' is not an valid IPv4 or IPv6 address"); + TreeSocket::OnError(I_ERR_BIND); + return; + } + else if (bind.family() != dest.family()) + { + state = I_ERROR; + SetError("Bind address '" + bind.addr() + "' is not the same address family as destination address '" + dest.addr() + "'"); + TreeSocket::OnError(I_ERR_BIND); + return; + } } DoConnect(dest, bind, link->Timeout);