aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-12-28 13:28:07 +0000
committerGravatar Sadie Powell2025-12-28 13:28:07 +0000
commite56e9b21ece7bb797a439096dc6927df6787d506 (patch)
tree222a51b734d92f29723f930cc4a6a3b77213f4bb
parentAvoid sending S2S tags to 1205 protocol servers. (diff)
Avoid excessively long FJOINs when using the 1205 protocol.
-rw-r--r--src/modules/m_spanningtree/compat.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index c41b8e45b..52d885a0e 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -20,6 +20,9 @@
#include "inspircd.h"
#include "main.h"
+// The maximum line length in the 1205 protocol
+#define COMPAT_LINE_LEN 510
+
namespace
{
size_t NextToken(const std::string& line, size_t start)
@@ -129,6 +132,27 @@ void TreeSocket::WriteLine(const std::string& original_line)
line.erase(displayend);
}
}
+ else if (irc::equals(command, "FJOIN"))
+ {
+ // FJOIN has no length limit in v4
+ // :<sid> FJOIN <chan> <TS> <modes> :[<member> [<member> ...]]
+ const auto chanend = NextToken(line, cmdend);
+ const auto chantsend = NextToken(line, chanend);
+ const auto modesend = NextToken(line, chantsend);
+ if (modesend != std::string::npos)
+ {
+ const auto maxlinelen = cmdstart + COMPAT_LINE_LEN;
+ while (line.length() > maxlinelen)
+ {
+ auto lastpos = line.rfind(' ', maxlinelen);
+ if (lastpos != std::string::npos)
+ {
+ WriteLineInternal(line.substr(0, lastpos));
+ line.erase(modesend, lastpos - modesend);
+ }
+ }
+ }
+ }
else if (irc::equals(command, "LMODE"))
{
// LMODE is new in v4; downgrade to FMODE.