From f88fbaa2fe91c22f1c7280ecd96c2bcf92f73a4d Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Thu, 11 Aug 2022 14:20:18 +0100
Subject: Move aptosa/untosa into the sockaddrs union and add from/from_ip.
The struct will also now always be zero-initialized by default which
removes the footgun which has happened previously where the union has
been accessed before being initialized leading to it containing weird
values.
---
src/modules/m_spanningtree/treesocket1.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'src/modules/m_spanningtree/treesocket1.cpp')
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 7cf1e170c..f66227084 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -48,10 +48,9 @@ TreeSocket::TreeSocket(std::shared_ptr link, std::shared_ptr
capab->ac = myac;
irc::sockets::sockaddrs bind;
- memset(&bind, 0, sizeof(bind));
if (!link->Bind.empty() && (dest.family() == AF_INET || dest.family() == AF_INET6))
{
- if (!irc::sockets::aptosa(link->Bind, 0, bind))
+ if (!bind.from_ip(link->Bind))
{
state = I_ERROR;
SetError("Bind address '" + link->Bind + "' is not a valid IPv4 or IPv6 address");
--
cgit v1.3.1-10-gc9f91