From 03254742e55f44b70e6c13f4bf380b0ddb3d0133 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 2 Aug 2020 00:21:20 +0000 Subject: [PATCH] epee: further defending against exceptions in command handlers --- contrib/epee/include/storages/levin_abstract_invoke2.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h index de8107781..e9625f0ce 100644 --- a/contrib/epee/include/storages/levin_abstract_invoke2.h +++ b/contrib/epee/include/storages/levin_abstract_invoke2.h @@ -290,6 +290,7 @@ namespace epee #define BEGIN_INVOKE_MAP2(owner_type) \ template int handle_invoke_map(bool is_notify, int command, const epee::span in_buff, std::string& buff_out, t_context& context, bool& handled) \ { \ + try { \ typedef owner_type internal_owner_type_name; #define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out) \ @@ -335,7 +336,13 @@ namespace epee LOG_ERROR("Unknown command:" << command); \ on_levin_traffic(context, false, false, true, in_buff.size(), "invalid-command"); \ return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED; \ + } \ + catch (const std::exception &e) { \ + MERROR("Error in handle_invoke_map: " << e.what()); \ + return LEVIN_ERROR_CONNECTION_TIMEDOUT; /* seems kinda appropriate */ \ + } \ } + } }