Просмотр исходного кода

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

ghassmo 4 лет назад
Родитель
Сommit
43fb491702
1 измененных файлов с 5 добавлено и 1 удалено
  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.