diff options
| author | 2017-12-23 14:53:57 +0000 | |
|---|---|---|
| committer | 2017-12-23 15:35:50 +0000 | |
| commit | 198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912 (patch) | |
| tree | 3d8edf303aa3e1ec267a98094ef4b917fb13d586 /src/modules/m_chghost.cpp | |
| parent | Fix User::ChangeRealHost() to change the real host properly. (diff) | |
| download | inspircd++-198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912.tar.gz inspircd++-198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912.tar.bz2 inspircd++-198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912.zip | |
Use a bitset in chghost/sethost instead of a char array.
Diffstat (limited to 'src/modules/m_chghost.cpp')
| -rw-r--r-- | src/modules/m_chghost.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 30efd1390..cda13c976 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -25,9 +25,11 @@ */ class CommandChghost : public Command { - char* hostmap; public: - CommandChghost(Module* Creator, char* hmap) : Command(Creator,"CHGHOST", 2), hostmap(hmap) + std::bitset<UCHAR_MAX> hostmap; + + CommandChghost(Module* Creator) + : Command(Creator,"CHGHOST", 2) { allow_empty_last_param = false; flags_needed = 'o'; @@ -45,7 +47,7 @@ class CommandChghost : public Command for (std::string::const_iterator x = parameters[1].begin(); x != parameters[1].end(); x++) { - if (!hostmap[(unsigned char)*x]) + if (!hostmap.test(*x)) { user->WriteNotice("*** CHGHOST: Invalid characters in hostname"); return CMD_FAILURE; @@ -83,10 +85,10 @@ class CommandChghost : public Command class ModuleChgHost : public Module { CommandChghost cmd; - char hostmap[256]; public: - ModuleChgHost() : cmd(this, hostmap) + ModuleChgHost() + : cmd(this) { } @@ -94,9 +96,9 @@ class ModuleChgHost : 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(*n); } Version GetVersion() CXX11_OVERRIDE |
