From a075001a7361cbd36a134969e50525ba7b490bf2 Mon Sep 17 00:00:00 2001 From: xirvik Date: Mon, 10 Aug 2026 02:22:50 +0000 Subject: [PATCH] Catch every json exception when processing a JSONRPC request. A number overflow escaped the two handlers and killed the process. --- src/rpc/jsonrpc.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/rpc/jsonrpc.cc b/src/rpc/jsonrpc.cc index 294e292c..77e68479 100644 --- a/src/rpc/jsonrpc.cc +++ b/src/rpc/jsonrpc.cc @@ -258,11 +258,8 @@ JsonRpc::process(const char* in_buffer, uint32_t length, slot_write callback) { return callback(response_str.c_str(), response_str.size()); - } catch (json::parse_error& e) { - auto err_str = json_error(JSONRPC_PARSE_ERROR, e.what(), nullptr).dump(-1, ' ', false, json::error_handler_t::replace); - return callback(err_str.c_str(), err_str.size()); - } catch (json::type_error& e) { - // Type errors may be caused by invalid UTF-8 strings in exception strings, hence the ::replace + } catch (json::exception& e) { + // Exception strings may contain invalid UTF-8, hence the ::replace auto err_str = json_error(JSONRPC_PARSE_ERROR, e.what(), nullptr).dump(-1, ' ', false, json::error_handler_t::replace); return callback(err_str.c_str(), err_str.size()); }