mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 12:27:44 +02:00
Fix missing check for error code after header is parsed:
The missing error check leads to completely ignoring the body limit, as the body limit is compared to the "Content-Length" header inside the "finish_header" method. closes #2201
This commit is contained in:
committed by
Richard Hodges
parent
26e9a4c294
commit
31a1fb332a
@ -1,4 +1,5 @@
|
||||
* Fix case where inflated content is larger than out buffer.
|
||||
* Fix missing check for error code after header is parsed.
|
||||
* Fix case where inflated content is larger than the out buffer.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -164,6 +164,8 @@ loop:
|
||||
goto done;
|
||||
}
|
||||
finish_header(ec, is_request{});
|
||||
if(ec)
|
||||
goto done;
|
||||
break;
|
||||
|
||||
case state::body0:
|
||||
|
@ -1517,6 +1517,23 @@ public:
|
||||
BEAST_EXPECTS(!ec, ec.message());
|
||||
}
|
||||
|
||||
void
|
||||
testIssue2201()
|
||||
{
|
||||
const char data[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
"\r\n"
|
||||
"*****";
|
||||
|
||||
test_parser<false> p;
|
||||
p.eager(true);
|
||||
p.body_limit(3);
|
||||
error_code ec;
|
||||
p.put(net::buffer(data, strlen(data)), ec);
|
||||
BEAST_EXPECT(ec == error::body_limit);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
@ -1546,6 +1563,7 @@ public:
|
||||
testChunkedOverflow();
|
||||
testChunkedBodySize();
|
||||
testUnlimitedBody();
|
||||
testIssue2201();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -104,6 +104,8 @@ public:
|
||||
boost::optional<std::uint64_t> const& content_length_,
|
||||
error_code& ec)
|
||||
{
|
||||
// The real implementation clears out the error code in basic_string_body::reader::init
|
||||
ec = {};
|
||||
++got_on_body;
|
||||
got_content_length =
|
||||
static_cast<bool>(content_length_);
|
||||
|
Reference in New Issue
Block a user