aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-03-05 13:56:54 -0500
committerluigi1111 <luigi1111w@gmail.com>2021-03-05 13:56:54 -0500
commit0b6bfb1fd891a292179cdf0b181ab29b717fc72e (patch)
tree383c742aff83dc8de071ee943bd623ded7e0a225 /contrib/epee/include/net
parentMerge pull request #7389 (diff)
parentepee: return HTTP error 400 (Bad request) on deserialization error (diff)
downloadmonero-0b6bfb1fd891a292179cdf0b181ab29b717fc72e.tar.xz
Merge pull request #7399
556af11 epee: return HTTP error 400 (Bad request) on deserialization error (moneromooo-monero)
Diffstat (limited to 'contrib/epee/include/net')
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index 1665fdac7..ffb3f3b7e 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -74,7 +74,13 @@
uint64_t ticks = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::request> req; \
bool parse_res = epee::serialization::load_t_from_json(static_cast<command_type::request&>(req), query_info.m_body); \
- CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse json: \r\n" << query_info.m_body); \
+ if (!parse_res) \
+ { \
+ MERROR("Failed to parse json: \r\n" << query_info.m_body); \
+ response_info.m_response_code = 400; \
+ response_info.m_response_comment = "Bad request"; \
+ return true; \
+ } \
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\
MINFO(m_conn_context << "calling " << s_pattern); \
@@ -104,7 +110,13 @@
uint64_t ticks = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::request> req; \
bool parse_res = epee::serialization::load_t_from_binary(static_cast<command_type::request&>(req), epee::strspan<uint8_t>(query_info.m_body)); \
- CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse bin body data, body size=" << query_info.m_body.size()); \
+ if (!parse_res) \
+ { \
+ MERROR("Failed to parse bin body data, body size=" << query_info.m_body.size()); \
+ response_info.m_response_code = 400; \
+ response_info.m_response_comment = "Bad request"; \
+ return true; \
+ } \
uint64_t ticks1 = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\
MINFO(m_conn_context << "calling " << s_pattern); \