From aac9fe1921a1c46aad240aa0fb990e7907782cf0 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 9 Dec 2022 10:17:36 +0000 Subject: Fix sending malformed MOTD and showfile messages to clients. --- src/modules/m_opermotd.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/modules/m_opermotd.cpp') diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index e833af282..3364b5a5a 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -74,12 +74,8 @@ class CommandOpermotd : public Command } user->WriteRemoteNumeric(RPL_OMOTDSTART, "Server operators message of the day"); - for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i) - { - user->WriteRemoteNumeric(RPL_OMOTD, InspIRCd::Format(" %s", i->c_str())); - } - + user->WriteRemoteNumeric(RPL_OMOTD, *i); user->WriteRemoteNumeric(RPL_ENDOFOMOTD, "End of OPERMOTD"); } }; @@ -116,7 +112,19 @@ class ModuleOpermotd : public Module try { FileReader reader(conf->getString("file", "opermotd", 1)); - cmd.opermotd = reader.GetVector(); + + const file_cache& lines = reader.GetVector(); + + // Process the MOTD entry. + cmd.opermotd.reserve(lines.size()); + for (file_cache::const_iterator it = lines.begin(); it != lines.end(); ++it) + { + // Some clients can not handle receiving RPL_OMOTD with an empty + // trailing parameter so if a line is empty we replace it with + // a single space. + const std::string& line = *it; + cmd.opermotd.push_back(line.empty() ? " " : line); + } InspIRCd::ProcessColors(cmd.opermotd); } catch (CoreException&) -- cgit v1.3.1-10-gc9f91