Эх сурвалжийг харах

ircd/server: Avoid DoS when receiving empty lines from clients.

Luther Blissett 3 жил өмнө
parent
commit
5f1f79d4c5

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

@@ -511,6 +511,11 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcServerConnection<C>
             return Err(Error::ChannelStopped)
         }
 
+        if line == "\n" || line == "\r\n" {
+            warn!("Closing connection.");
+            return Err(Error::ChannelStopped)
+        }
+
         if &line[(line.len() - 2)..] == "\r\n" {
             // Remove CRLF
             line.pop();
@@ -522,11 +527,6 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcServerConnection<C>
             return Err(Error::ChannelStopped)
         }
 
-        if line == "\n" {
-            warn!("Closing connection.");
-            return Err(Error::ChannelStopped)
-        }
-
         Ok(line.clone())
     }
 }