Added a check for malformed request paths

This commit is contained in:
2025-03-18 22:12:46 +01:00
parent 2fd0d4f64f
commit 065b181530
3 changed files with 30 additions and 1 deletions

View File

@ -157,7 +157,14 @@ func (s *server) handleConnection(conn net.Conn) {
lastSpace = len(message) - len("\r\n")
}
url = message[space+1 : lastSpace]
space += 1
if space > lastSpace {
io.WriteString(conn, "HTTP/1.1 400 Bad Request\r\n\r\n")
return
}
url = message[space:lastSpace]
// Add headers until we meet an empty line
for {