Catch every json exception when processing a JSONRPC request.

A number overflow escaped the two handlers and killed the process.
This commit is contained in:
xirvik
2026-08-10 02:22:50 +00:00
committed by Jari Sundell
parent 781520fef8
commit a075001a73
+2 -5
View File
@@ -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());
}