X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=f8a1bd330a77b9a3941e0325bf7e9718c259d3fc;hb=58385dd458e927994957b6d603f7f9da3fc52e14;hp=43ebfe0a3a2df1d6ac71b648d6afb0d498f7537f;hpb=20680f9c4964a5e10e3649a1e479078ff85c5c85;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 43ebfe0a3..f8a1bd330 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -193,11 +193,10 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance Visibility = NULL; ip = NULL; MyClass = NULL; + io = NULL; AllowedUserModes = NULL; AllowedChanModes = NULL; AllowedOperCommands = NULL; - memset(AllowedUserModes, 0, sizeof(AllowedUserModes)); - memset(AllowedChanModes, 0, sizeof(AllowedChanModes)); chans.clear(); invites.clear(); memset(modes,0,sizeof(modes)); @@ -225,7 +224,7 @@ User::~User() if (this->MyClass) { this->MyClass->RefCount--; - ServerInstance->Logs->Log("USERS", DEBUG, "User destructor -- connect refcount now: %u", this->MyClass->RefCount); + ServerInstance->Logs->Log("USERS", DEBUG, "User destructor -- connect refcount now: %lu", this->MyClass->RefCount); } if (this->AllowedOperCommands) { @@ -235,13 +234,13 @@ User::~User() if (this->AllowedUserModes) { - delete AllowedUserModes; + delete[] AllowedUserModes; AllowedUserModes = NULL; } if (this->AllowedChanModes) { - delete AllowedChanModes; + delete[] AllowedChanModes; AllowedChanModes = NULL; } @@ -521,7 +520,7 @@ bool User::AddBuffer(std::string a) if (this->MyClass && (recvq.length() > this->MyClass->GetRecvqMax())) { this->SetWriteError("RecvQ exceeded"); - ServerInstance->SNO->WriteToSnoMask('A', "User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->MyClass->GetRecvqMax()); + ServerInstance->SNO->WriteToSnoMask('A', "User %s RecvQ of %d exceeds connect class maximum of %lu",this->nick,recvq.length(),this->MyClass->GetRecvqMax()); return false; } @@ -598,7 +597,7 @@ void User::AddWriteBuf(const std::string &data) * to repeatedly add the text to the sendq! */ this->SetWriteError("SendQ exceeded"); - ServerInstance->SNO->WriteToSnoMask('A', "User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->MyClass->GetSendqMax()); + ServerInstance->SNO->WriteToSnoMask('A', "User %s SendQ of %d exceeds connect class maximum of %lu",this->nick,sendq.length() + data.length(),this->MyClass->GetSendqMax()); return; } @@ -729,7 +728,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) { if (*c == '*') { - memset(this->AllowedUserModes, (int)(true), sizeof(this->AllowedUserModes)); + memset(this->AllowedUserModes, (int)(true), 64); } else { @@ -740,7 +739,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) { if (*c == '*') { - memset(this->AllowedChanModes, (int)(true), sizeof(this->AllowedChanModes)); + memset(this->AllowedChanModes, (int)(true), 64); } else { @@ -794,6 +793,17 @@ void User::UnOper() delete AllowedOperCommands; AllowedOperCommands = NULL; } + if (AllowedUserModes) + { + delete[] AllowedUserModes; + AllowedUserModes = NULL; + } + if (AllowedChanModes) + { + delete[] AllowedChanModes; + AllowedChanModes = NULL; + } + } } @@ -1156,14 +1166,14 @@ void User::Write(std::string text) return; } - if (ServerInstance->Config->GetIOHook(this->GetPort())) + if (this->io) { /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to * implement their own buffering mechanisms */ try { - ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length()); + this->io->OnRawSocketWrite(this->fd, text.data(), text.length()); } catch (CoreException& modexcept) { @@ -1698,7 +1708,7 @@ ConnectClass* User::SetClass(const std::string &explicit_name) /* deny change if change will take class over the limit */ if (found->limit && (found->RefCount + 1 >= found->limit)) { - ServerInstance->Logs->Log("USERS", DEBUG, "OOPS: Connect class limit (%u) hit, denying", found->limit); + ServerInstance->Logs->Log("USERS", DEBUG, "OOPS: Connect class limit (%lu) hit, denying", found->limit); return this->MyClass; } @@ -1708,12 +1718,12 @@ ConnectClass* User::SetClass(const std::string &explicit_name) if (found == this->MyClass) // no point changing this shit :P return this->MyClass; this->MyClass->RefCount--; - ServerInstance->Logs->Log("USERS", DEBUG, "Untying user from connect class -- refcount: %u", this->MyClass->RefCount); + ServerInstance->Logs->Log("USERS", DEBUG, "Untying user from connect class -- refcount: %lu", this->MyClass->RefCount); } this->MyClass = found; this->MyClass->RefCount++; - ServerInstance->Logs->Log("USERS", DEBUG, "User tied to new class -- connect refcount now: %u", this->MyClass->RefCount); + ServerInstance->Logs->Log("USERS", DEBUG, "User tied to new class -- connect refcount now: %lu", this->MyClass->RefCount); } return this->MyClass;