mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
smtpsrv: Limit incoming line length and improve large message handling
Currently, there is no limit to incoming line length, so an evil client could cause a memory exhaustion DoS by issuing very long lines. This patch fixes the bug by limiting the size of the lines. To do that, we replace the textproto.Conn with a pair of buffered reader and writer, which simplify the code and allow for better and cleaner control. Thanks to Max Mazurov (fox.cpp@disroot.org) for finding and reporting this issue.
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"flag"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
@@ -247,7 +246,6 @@ func (s *Server) serve(l net.Listener, mode SocketMode) {
|
||||
maxDataSize: s.MaxDataSize,
|
||||
postDataHook: pdhook,
|
||||
conn: conn,
|
||||
tc: textproto.NewConn(conn),
|
||||
mode: mode,
|
||||
tlsConfig: s.tlsConfig,
|
||||
onTLS: mode.TLS,
|
||||
|
||||
Reference in New Issue
Block a user