X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=43ebfe0a3a2df1d6ac71b648d6afb0d498f7537f;hb=20680f9c4964a5e10e3649a1e479078ff85c5c85;hp=bdceba1f5038a7587df82004a0843dfadb8f595e;hpb=743c10e4ca5acd45e670b335a07b5bf3ab754ab6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index bdceba1f5..43ebfe0a3 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -193,6 +193,8 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance Visibility = NULL; ip = NULL; MyClass = NULL; + AllowedUserModes = NULL; + AllowedChanModes = NULL; AllowedOperCommands = NULL; memset(AllowedUserModes, 0, sizeof(AllowedUserModes)); memset(AllowedChanModes, 0, sizeof(AllowedChanModes)); @@ -231,6 +233,18 @@ User::~User() AllowedOperCommands = NULL; } + if (this->AllowedUserModes) + { + delete AllowedUserModes; + AllowedUserModes = NULL; + } + + if (this->AllowedChanModes) + { + delete AllowedChanModes; + AllowedChanModes = NULL; + } + this->InvalidateCache(); this->DecrementModes(); @@ -447,6 +461,9 @@ bool User::HasModePermission(unsigned char mode, ModeType type) if (!IS_OPER(this)) return false; + if (!AllowedUserModes || !AllowedChanModes) + return false; + return ((type == MODETYPE_USER ? AllowedUserModes : AllowedChanModes))[(mode - 'A')]; } @@ -683,6 +700,15 @@ void User::Oper(const std::string &opertype, const std::string &opername) else AllowedOperCommands = new std::map; + if (!AllowedChanModes) + AllowedChanModes = new bool[64]; + + if (!AllowedUserModes) + AllowedUserModes = new bool[64]; + + memset(AllowedUserModes, 0, 64); + memset(AllowedChanModes, 0, 64); + char* Classes = strdup(iter_opertype->second); char* myclass = strtok_r(Classes," ",&savept); while (myclass)