]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
CAP TLS now implemented, this needs someone to make a client to test it :p
[user/henk/code/inspircd.git] / src / users.cpp
index bdceba1f5038a7587df82004a0843dfadb8f595e..46665396f0300297613ac61fc3e95b5f8fd009cf 100644 (file)
@@ -193,9 +193,9 @@ 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));
        chans.clear();
        invites.clear();
        memset(modes,0,sizeof(modes));
@@ -231,6 +231,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 +459,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 +698,15 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                        else
                                AllowedOperCommands = new std::map<std::string, bool>;
 
+                       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)
@@ -703,7 +727,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
                                                {
@@ -714,7 +738,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
                                                {
@@ -768,6 +792,17 @@ void User::UnOper()
                        delete AllowedOperCommands;
                        AllowedOperCommands = NULL;
                }
+               if (AllowedUserModes)
+               {
+                       delete[] AllowedUserModes;
+                       AllowedUserModes = NULL;
+               }
+               if (AllowedChanModes)
+               {
+                       delete[] AllowedChanModes;
+                       AllowedChanModes = NULL;
+               }
+
        }
 }