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/uid.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/modules/m_spanningtree/uid.cpp') diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index bd878d488..9fe9069a0 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -70,12 +70,8 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params } } - irc::sockets::sockaddrs sa; - if (params[6].find('/') != std::string::npos) - irc::sockets::untosa(params[6], sa); - else - irc::sockets::aptosa(params[6], 0, sa); - if (sa.family() == AF_UNSPEC) + irc::sockets::sockaddrs sa(false); + if (!sa.from(params[6])) throw ProtocolException("Invalid IP address or UNIX socket path"); /* For remote users, we pass the UUID they sent to the constructor. -- cgit v1.3.1-10-gc9f91