mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 14:14:00 +01:00
http: Restrict maximum size of request line + headers
Prevent memory exhaustion by sending lots of data. Also add a test to `httpbasics.py`. Closes #6425
This commit is contained in:
@@ -38,6 +38,9 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
/** Maximum size of http request (request line + headers) */
|
||||
static const size_t MAX_HEADERS_SIZE = 8192;
|
||||
|
||||
/** HTTP request work item */
|
||||
class HTTPWorkItem : public HTTPClosure
|
||||
{
|
||||
@@ -414,6 +417,7 @@ bool InitHTTPServer()
|
||||
}
|
||||
|
||||
evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
|
||||
evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE);
|
||||
evhttp_set_max_body_size(http, MAX_SIZE);
|
||||
evhttp_set_gencb(http, http_request_cb, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user