X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sethost.cpp;h=87eed402284bbd09a3dc31ece342ff9ce6a6fcab;hb=384ef31bc01e4a1a2e59d082c9066002410ba54a;hp=b37207b4fa7e93020aa3bb13ac0d795c9225bc52;hpb=d865b434865907bfad0a187dd403d4ca8144e469;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index b37207b4f..87eed4022 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -25,16 +25,17 @@ */ class CommandSethost : public Command { - char* hostmap; - public: - CommandSethost(Module* Creator, char* hmap) : Command(Creator,"SETHOST", 1), hostmap(hmap) + std::bitset hostmap; + + CommandSethost(Module* Creator) + : Command(Creator,"SETHOST", 1) { allow_empty_last_param = false; flags_needed = 'o'; syntax = ""; } - CmdResult Handle (const std::vector& parameters, User *user) + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { if (parameters[0].length() > ServerInstance->Config->Limits.MaxHost) { @@ -44,7 +45,7 @@ class CommandSethost : public Command for (std::string::const_iterator x = parameters[0].begin(); x != parameters[0].end(); x++) { - if (!hostmap[(const unsigned char)*x]) + if (!hostmap.test(static_cast(*x))) { user->WriteNotice("*** SETHOST: Invalid characters in hostname"); return CMD_FAILURE; @@ -65,11 +66,10 @@ class CommandSethost : public Command class ModuleSetHost : public Module { CommandSethost cmd; - char hostmap[256]; public: ModuleSetHost() - : cmd(this, hostmap) + : cmd(this) { } @@ -77,9 +77,9 @@ class ModuleSetHost : public Module { std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"); - memset(hostmap, 0, sizeof(hostmap)); + cmd.hostmap.reset(); for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++) - hostmap[(unsigned char)*n] = 1; + cmd.hostmap.set(static_cast(*n)); } Version GetVersion() CXX11_OVERRIDE