mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 05:17:26 +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;
|
goto done;
|
||||||
}
|
}
|
||||||
finish_header(ec, is_request{});
|
finish_header(ec, is_request{});
|
||||||
|
if(ec)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case state::body0:
|
case state::body0:
|
||||||
|
@ -1517,6 +1517,23 @@ public:
|
|||||||
BEAST_EXPECTS(!ec, ec.message());
|
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
|
void
|
||||||
@ -1546,6 +1563,7 @@ public:
|
|||||||
testChunkedOverflow();
|
testChunkedOverflow();
|
||||||
testChunkedBodySize();
|
testChunkedBodySize();
|
||||||
testUnlimitedBody();
|
testUnlimitedBody();
|
||||||
|
testIssue2201();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,6 +104,8 @@ public:
|
|||||||
boost::optional<std::uint64_t> const& content_length_,
|
boost::optional<std::uint64_t> const& content_length_,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
|
// The real implementation clears out the error code in basic_string_body::reader::init
|
||||||
|
ec = {};
|
||||||
++got_on_body;
|
++got_on_body;
|
||||||
got_content_length =
|
got_content_length =
|
||||||
static_cast<bool>(content_length_);
|
static_cast<bool>(content_length_);
|
||||||
|
Reference in New Issue
Block a user