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_gateway.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/modules/m_gateway.cpp') diff --git a/src/modules/m_gateway.cpp b/src/modules/m_gateway.cpp index a00d2d0df..d4a9a3d7b 100644 --- a/src/modules/m_gateway.cpp +++ b/src/modules/m_gateway.cpp @@ -140,8 +140,8 @@ public: CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { - irc::sockets::sockaddrs sa; - if (irc::sockets::aptosa(parameters[0], 0, sa)) + irc::sockets::sockaddrs sa(false); + if (sa.from_ip(parameters[0])) { if (sa.family() != AF_INET) { @@ -263,8 +263,8 @@ public: if (!host.Matches(user, parameters[0], sslapi)) continue; - irc::sockets::sockaddrs ipaddr; - if (!irc::sockets::aptosa(parameters[3], user->client_sa.port(), ipaddr)) + irc::sockets::sockaddrs ipaddr(false); + if (!ipaddr.from_ip_port(parameters[3], user->client_sa.port())) { ServerInstance->SNO.WriteGlobalSno('w', "Connecting user %s (%s) tried to use WEBIRC but gave an invalid IP address.", user->uuid.c_str(), user->GetIPString().c_str()); -- cgit v1.3.1-10-gc9f91