]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: set header/body size limits on beast parser
authorCasey Bodley <cbodley@redhat.com>
Tue, 11 Jul 2017 20:12:02 +0000 (16:12 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 8 Jan 2018 21:29:57 +0000 (16:29 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1f72684eb4c6fb9fd021240ae55812894afc19e9)

src/rgw/rgw_asio_frontend.cc

index 6c776ce41b831521f9472907e75da753387d2032..ddc5faebfc0e138833d5107f532025811a037b73 100644 (file)
@@ -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<size_t>::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 ||