summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-10-11 12:21:16 +0100
committerPeter Powell <petpow@saberuk.com>2019-10-13 22:05:19 +0100
commitdd24f8ac713793d5d5a7e959228937f48788ba66 (patch)
tree1f55ed9c83ad62acdb628f77f0b347044f26d61a
parentf751aef21057d8b4be40cdb697982ea3e53e992c (diff)
Convert a bunch of LocalUser* casts to IS_LOCAL.
This is a lot safer and handles users changing servers properly.
-rw-r--r--src/coremods/core_hostname_lookup.cpp4
-rw-r--r--src/modules/m_cloaking.cpp6
-rw-r--r--src/modules/m_dnsbl.cpp4
-rw-r--r--src/modules/m_ldapauth.cpp2
-rw-r--r--src/modules/m_namedmodes.cpp5
-rw-r--r--src/modules/m_sqlauth.cpp2
6 files changed, 13 insertions, 10 deletions
diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp
index 85d0f530c..13214115b 100644
--- a/src/coremods/core_hostname_lookup.cpp
+++ b/src/coremods/core_hostname_lookup.cpp
@@ -58,7 +58,7 @@ class UserResolver : public DNS::Request
*/
void OnLookupComplete(const DNS::Query* r) CXX11_OVERRIDE
{
- LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid);
+ LocalUser* bound_user = IS_LOCAL(ServerInstance->FindUUID(uuid));
if (!bound_user)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resolution finished for user '%s' who is gone", uuid.c_str());
@@ -166,7 +166,7 @@ class UserResolver : public DNS::Request
*/
void OnError(const DNS::Query* query) CXX11_OVERRIDE
{
- LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid);
+ LocalUser* bound_user = IS_LOCAL(ServerInstance->FindUUID(uuid));
if (bound_user)
{
bound_user->WriteNotice("*** Could not resolve your hostname: " + this->manager->GetErrorStr(query->error) + "; using your IP address (" + bound_user->GetIPString() + ") instead.");
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index c5db9ff8a..eab28db4a 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -375,12 +375,14 @@ class ModuleCloaking : public Module
{
u->SetMode(cu, false);
- if (!IS_LOCAL(u))
+ LocalUser* luser = IS_LOCAL(u);
+ if (!luser)
return;
+
Modes::ChangeList modechangelist;
modechangelist.push_remove(&cu);
ClientProtocol::Events::Mode modeevent(ServerInstance->FakeClient, NULL, u, modechangelist);
- static_cast<LocalUser*>(u)->Send(modeevent);
+ luser->Send(modeevent);
}
cu.active = false;
}
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 9a9ad85a2..c9be107b8 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -63,7 +63,7 @@ class DNSBLResolver : public DNS::Request
void OnLookupComplete(const DNS::Query *r) CXX11_OVERRIDE
{
/* Check the user still exists */
- LocalUser* them = (LocalUser*)ServerInstance->FindUUID(theiruid);
+ LocalUser* them = IS_LOCAL(ServerInstance->FindUUID(theiruid));
if (!them)
return;
@@ -209,7 +209,7 @@ class DNSBLResolver : public DNS::Request
void OnError(const DNS::Query *q) CXX11_OVERRIDE
{
- LocalUser* them = (LocalUser*)ServerInstance->FindUUID(theiruid);
+ LocalUser* them = IS_LOCAL(ServerInstance->FindUUID(theiruid));
if (!them)
return;
diff --git a/src/modules/m_ldapauth.cpp b/src/modules/m_ldapauth.cpp
index b833b9384..845fc6fbd 100644
--- a/src/modules/m_ldapauth.cpp
+++ b/src/modules/m_ldapauth.cpp
@@ -216,7 +216,7 @@ class SearchInterface : public LDAPInterface
void OnResult(const LDAPResult& r) CXX11_OVERRIDE
{
- LocalUser* user = static_cast<LocalUser*>(ServerInstance->FindUUID(uid));
+ LocalUser* user = IS_LOCAL(ServerInstance->FindUUID(uid));
dynamic_reference<LDAPProvider> LDAP(me, provider);
if (!LDAP || r.empty() || !user)
{
diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp
index 2fbdca265..af520080f 100644
--- a/src/modules/m_namedmodes.cpp
+++ b/src/modules/m_namedmodes.cpp
@@ -113,8 +113,9 @@ class DummyZ : public ModeHandler
// Handle /MODE #chan Z
void DisplayList(User* user, Channel* chan) CXX11_OVERRIDE
{
- if (IS_LOCAL(user))
- ::DisplayList(static_cast<LocalUser*>(user), chan);
+ LocalUser* luser = IS_LOCAL(user);
+ if (luser)
+ ::DisplayList(luser, chan);
}
};
diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp
index 54ff7e088..503215eb2 100644
--- a/src/modules/m_sqlauth.cpp
+++ b/src/modules/m_sqlauth.cpp
@@ -49,7 +49,7 @@ class AuthQuery : public SQL::Query
void OnResult(SQL::Result& res) CXX11_OVERRIDE
{
- LocalUser* user = static_cast<LocalUser*>(ServerInstance->FindUUID(uid));
+ LocalUser* user = IS_LOCAL(ServerInstance->FindUUID(uid));
if (!user)
return;