fix using chunked mode with HTTP/1.0

According to RFC 7230, Transfer-Encoding was added in HTTP/1.1. Such a
header in a HTTP/1.0 message should be ignored. Interpreting it can be
harmful when sending a HTTP/1.0 message because the parser would
indefinitely wait for a chunk size instead of parsing the message's
body as non-chunked, leading to a HTTP content evasion.
This commit is contained in:
jbencteux 2018-04-13 16:11:55 +02:00 committed by Jon Siwek
parent 2e2d086144
commit ec4a936f66
2 changed files with 13 additions and 1 deletions

View file

@ -470,8 +470,15 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h)
else if ( mime::strcasecmp_n(h->get_name(), "transfer-encoding") == 0 )
{
double http_version = 0;
if (http_message->analyzer->GetRequestOngoing())
http_version = http_message->analyzer->GetRequestVersion();
else // reply_ongoing
http_version = http_message->analyzer->GetReplyVersion();
data_chunk_t vt = h->get_value_token();
if ( mime::strcasecmp_n(vt, "chunked") == 0 )
if ( mime::strcasecmp_n(vt, "chunked") == 0 &&
http_version == 1.1)
chunked_transfer_state = BEFORE_CHUNK;
}