aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2023-01-01 10:10:28 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2023-01-01 10:10:28 +0000
commitb67e931843cd0c8191ec49f80448c010cba39901 (patch)
tree9799136d26cd7780a54bdf64e8592913b0df10b2
parentMerge pull request #8635 (diff)
downloadmonero-b67e931843cd0c8191ec49f80448c010cba39901.tar.xz
epee: when loading a JSON RPC payload, ensure params is an object
this makes it easier to spot those mistakes by the caller
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index 848b8ffc4..00967b2da 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -152,6 +152,16 @@
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp), response_info.m_body); \
return true; \
} \
+ epee::serialization::storage_entry se; \
+ if(ps.get_value("params", se, nullptr) && se.type() != typeid(epee::serialization::section)) \
+ { \
+ boost::value_initialized<epee::json_rpc::error_response> rsp; \
+ static_cast<epee::json_rpc::error_response&>(rsp).jsonrpc = "2.0"; \
+ static_cast<epee::json_rpc::error_response&>(rsp).error.code = -32701; \
+ static_cast<epee::json_rpc::error_response&>(rsp).error.message = "Params is not an object"; \
+ epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp), response_info.m_body); \
+ return true; \
+ } \
epee::serialization::storage_entry id_; \
id_ = epee::serialization::storage_entry(std::string()); \
ps.get_value("id", id_, nullptr); \