summaryrefslogtreecommitdiff
path: root/src/modules/m_sethost.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-12-23 14:53:57 +0000
committerPeter Powell <petpow@saberuk.com>2017-12-23 15:35:50 +0000
commit198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912 (patch)
tree3d8edf303aa3e1ec267a98094ef4b917fb13d586 /src/modules/m_sethost.cpp
parent6efee33e920a15fb2bd14a4c5275f678d33318cb (diff)
Use a bitset in chghost/sethost instead of a char array.
Diffstat (limited to 'src/modules/m_sethost.cpp')
-rw-r--r--src/modules/m_sethost.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp
index 23dbbad56..b75bac425 100644
--- a/src/modules/m_sethost.cpp
+++ b/src/modules/m_sethost.cpp
@@ -25,10 +25,11 @@
*/
class CommandSethost : public Command
{
- char* hostmap;
-
public:
- CommandSethost(Module* Creator, char* hmap) : Command(Creator,"SETHOST", 1), hostmap(hmap)
+ std::bitset<UCHAR_MAX> hostmap;
+
+ CommandSethost(Module* Creator)
+ : Command(Creator,"SETHOST", 1)
{
allow_empty_last_param = false;
flags_needed = 'o'; syntax = "<new-hostname>";
@@ -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(*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(*n);
}
Version GetVersion() CXX11_OVERRIDE