Added a check for malformed request paths

This commit is contained in:
Eduard Urbach 2025-03-18 22:12:46 +01:00
parent 934e8e7206
commit cdad24e2f7
Signed by: eduard
GPG key ID: 49226B848C78F6C8
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 {