Explorar o código

bin/ircd: restrict irc messages to have a maximum length of 512 characters

ghassmo %!s(int64=4) %!d(string=hai) anos
pai
achega
43fb491702
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      bin/ircd/src/server.rs

+ 5 - 1
bin/ircd/src/server.rs

@@ -68,7 +68,11 @@ impl IrcServerConnection {
         }
     }
 
-    pub async fn update(&mut self, line: String) -> Result<()> {
+    async fn update(&mut self, line: String) -> Result<()> {
+        if line.len() > 513 {
+            return Err(Error::MalformedPacket)
+        }
+
         let mut tokens = line.split_ascii_whitespace();
         // Commands can begin with :garbage but we will reject clients doing
         // that for now to keep the protocol simple and focused.