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/users.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 37277643c..809fdb15a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -96,8 +96,6 @@ User::User(const std::string& uid, Server* srv, Type type) , uniqueusername(false) , usertype(type) { - client_sa.sa.sa_family = AF_UNSPEC; - ServerInstance->Logs.Debug("USERS", "New UUID for user: %s", uuid.c_str()); if (srv->IsService()) @@ -114,6 +112,7 @@ User::User(const std::string& uid, Server* srv, Type type) LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr) : User(ServerInstance->UIDGen.GetUID(), ServerInstance->FakeClient->server, User::TYPE_LOCAL) , eh(this) + , server_sa(*servaddr) , quitting_sendq(false) , lastping(true) , exempt(false) @@ -124,7 +123,6 @@ LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::so ident = uuid; eh.SetFd(myfd); memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs)); - memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs)); ChangeRealHost(GetIPString(), true); } -- cgit v1.3.1-10-gc9f91