diff options
author | luigi1111 <luigi1111w@gmail.com> | 2022-04-25 10:22:03 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2022-04-25 10:22:03 -0500 |
commit | 67e5ca9ad6f1c861ad315476a88f9d36c38a0abb (patch) | |
tree | e566972a68a03dd0447f8d1ab0cc3601c3bdf4d0 /contrib | |
parent | Merge pull request #8260 (diff) | |
parent | add a sanity check to RPC input data size (diff) | |
download | monero-67e5ca9ad6f1c861ad315476a88f9d36c38a0abb.tar.xz |
Merge pull request #8275
9209880 add a sanity check to RPC input data size (moneromooo-monero)
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/epee/include/net/http_protocol_handler.h | 2 | ||||
-rw-r--r-- | contrib/epee/include/net/http_protocol_handler.inl | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/contrib/epee/include/net/http_protocol_handler.h b/contrib/epee/include/net/http_protocol_handler.h index f68b2bc99..258b07e2c 100644 --- a/contrib/epee/include/net/http_protocol_handler.h +++ b/contrib/epee/include/net/http_protocol_handler.h @@ -55,6 +55,7 @@ namespace net_utils std::string m_folder; std::vector<std::string> m_access_control_origins; boost::optional<login> m_user; + size_t m_max_content_length{std::numeric_limits<size_t>::max()}; critical_section m_lock; }; @@ -141,6 +142,7 @@ namespace net_utils config_type& m_config; bool m_want_close; size_t m_newlines; + size_t m_bytes_read; protected: i_service_endpoint* m_psnd_hndlr; t_connection_context& m_conn_context; diff --git a/contrib/epee/include/net/http_protocol_handler.inl b/contrib/epee/include/net/http_protocol_handler.inl index df0afc5cf..f7d2074b2 100644 --- a/contrib/epee/include/net/http_protocol_handler.inl +++ b/contrib/epee/include/net/http_protocol_handler.inl @@ -206,6 +206,7 @@ namespace net_utils m_config(config), m_want_close(false), m_newlines(0), + m_bytes_read(0), m_psnd_hndlr(psnd_hndlr), m_conn_context(conn_context) { @@ -221,6 +222,7 @@ namespace net_utils m_query_info.clear(); m_len_summary = 0; m_newlines = 0; + m_bytes_read = 0; return true; } //-------------------------------------------------------------------------------------------- @@ -243,6 +245,14 @@ namespace net_utils size_t ndel; + m_bytes_read += buf.size(); + if (m_bytes_read > m_config.m_max_content_length) + { + LOG_ERROR("simple_http_connection_handler::handle_buff_in: Too much data: got " << m_bytes_read); + m_state = http_state_error; + return false; + } + if(m_cache.size()) m_cache += buf; else |