mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
Fixes #3847.
This commit is contained in:
@@ -153,6 +153,11 @@ proc processClient(client: AsyncSocket, address: string,
|
||||
if lineFut.mget == "\c\L": break
|
||||
let (key, value) = parseHeader(lineFut.mget)
|
||||
request.headers[key] = value
|
||||
# Ensure the client isn't trying to DoS us.
|
||||
if request.headers.len > headerLimit:
|
||||
await client.sendStatus("400 Bad Request")
|
||||
request.client.close()
|
||||
return
|
||||
|
||||
if request.reqMethod == "post":
|
||||
# Check for Expect header
|
||||
|
||||
@@ -242,6 +242,10 @@ proc parseResponse(s: Socket, getBody: bool, timeout: int): Response =
|
||||
inc(linei) # Skip :
|
||||
|
||||
result.headers[name] = line[linei.. ^1].strip()
|
||||
# Ensure the server isn't trying to DoS us.
|
||||
if result.headers.len > headerLimit:
|
||||
httpError("too many headers")
|
||||
|
||||
if not fullyRead:
|
||||
httpError("Connection was closed before full request has been made")
|
||||
if getBody:
|
||||
@@ -751,6 +755,9 @@ proc parseResponse(client: AsyncHttpClient,
|
||||
inc(linei) # Skip :
|
||||
|
||||
result.headers[name] = line[linei.. ^1].strip()
|
||||
if result.headers.len > headerLimit:
|
||||
httpError("too many headers")
|
||||
|
||||
if not fullyRead:
|
||||
httpError("Connection was closed before full request has been made")
|
||||
if getBody:
|
||||
|
||||
Reference in New Issue
Block a user