aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_sethost.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-09-30 20:33:49 +0100
committerGravatar Sadie Powell2022-09-30 20:33:49 +0100
commitb2c78ffe5972bacf1d511fab99310fd8e39c1fb5 (patch)
treee3c78fd96d0e1c183726cc3c25e72bf17d320100 /src/modules/m_sethost.cpp
parentUse a global typedef for representing a character set. (diff)
Prevent allowing weird characters within hostnames.
Diffstat (limited to 'src/modules/m_sethost.cpp')
-rw-r--r--src/modules/m_sethost.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp
index 769f51cb5..6f563a0d0 100644
--- a/src/modules/m_sethost.cpp
+++ b/src/modules/m_sethost.cpp
@@ -83,9 +83,15 @@ public:
auto tag = ServerInstance->Config->ConfValue("hostname");
const std::string hmap = tag->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789", 1);
- cmd.hostmap.reset();
+ CharState newhostmap;
for (const auto& chr : hmap)
- cmd.hostmap.set(static_cast<unsigned char>(chr));
+ {
+ // A hostname can not contain NUL, LF, CR, or SPACE.
+ if (chr == 0x00 || chr == 0x0A || chr == 0x0D || chr == 0x20)
+ throw ModuleException(this, InspIRCd::Format("<hostname:charmap> can not contain character 0x%02X (%c)", chr, chr));
+ newhostmap.set(static_cast<unsigned char>(chr));
+ }
+ std::swap(newhostmap, cmd.hostmap);
}
};