Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,24 @@ httpClientDiscardBody(HTTPConnectionPtr connection)
if(connection->reqte != TE_IDENTITY)
goto fail;

if(connection->bodylen < 0)
goto fail;

if(connection->bodylen < connection->reqlen - connection->reqbegin) {
if(connection->bodylen < 0) {
/* We don't know the body length, either because the request
was unparseable, or because it was something that doesn't
carry a Content-Length (e.g. CONNECT). We want to do the
right thing in the latter case, but don't care much about
the former. So we simply shut the connection down as soon
as we see any data coming after the headers. */
/* reqlen = -2 is used by DiscardHandler to signal that we
should shut down. */
if(connection->bodylen == -2)
goto fail;
if(connection->reqlen > connection->reqbegin)
goto fail;
connection->reqbegin = 0;
connection->reqlen = 0;
httpConnectionDestroyReqbuf(connection);
/* httpClientDiscardHander will call us back. */
} else if(connection->bodylen + connection->reqbegin < connection->reqlen) {
connection->reqbegin += connection->bodylen;
connection->bodylen = 0;
} else {
Expand Down Expand Up @@ -1062,7 +1076,7 @@ httpClientDiscardHandler(int status,
if(status) {
if(status < 0 && status != -EPIPE && status != -ECONNRESET)
do_log_error(L_ERROR, -status, "Couldn't read from client");
connection->bodylen = -1;
connection->bodylen = -2;
return httpClientDiscardBody(connection);
}

Expand Down