From: Casey Bodley Date: Tue, 11 Jul 2017 20:12:02 +0000 (-0400) Subject: rgw: set header/body size limits on beast parser X-Git-Tag: v12.2.3~126^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0a024c978b72402e4f8792c60c017d3ccbc60050;p=ceph.git rgw: set header/body size limits on beast parser Signed-off-by: Casey Bodley (cherry picked from commit 1f72684eb4c6fb9fd021240ae55812894afc19e9) --- diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index 6c776ce41b83..ddc5faebfc0e 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -72,12 +72,21 @@ static void handle_connection(RGWProcessEnv& env, tcp::socket socket, auto cct = env.store->ctx(); boost::system::error_code ec; - beast::flat_buffer buffer{4096}; + // limit header to 4k, since we read it all into a single buffer + constexpr size_t header_limit = 4096; + // don't impose a limit on the body, since we read it in pieces + constexpr size_t body_limit = std::numeric_limits::max(); + + beast::flat_buffer buffer; // read messages from the socket until eof for (;;) { - // parse the header + // configure the parser rgw::asio::parser_type parser; + parser.header_limit(header_limit); + parser.body_limit(body_limit); + + // parse the header beast::http::async_read_header(socket, buffer, parser, yield[ec]); if (ec == boost::asio::error::connection_reset ||