fix(libmsg): security audit round 3 - add server send timeout + harden RPC validation

This commit is contained in:
qing committed 2026-08-07 21:13:14 +08:00
1 parent 3c50a862d3
commit 63c22a3d60
3 files changed
+102 -10

No files matched your search

+6 -1
View File
@@ -126,7 +126,12 @@ public:
if (!obj.contains("success")) {
throw RpcError("非法 RPC 响应(缺少 success 字段): " + resp_str.substr(0, 200));
}
if (!obj.at("success").as_bool()) {
const json::value& success = obj.at("success");
if (!success.is_bool()) {
// 类型不符时不要调用 as_bool()(会抛未捕获的 boost system_error),统一抛 RpcError
throw RpcError("非法 RPC 响应(success 字段不是 bool)");
}
if (!success.as_bool()) {
std::string err = "未知错误";
if (auto it = obj.find("error"); it != obj.end() && it->value().is_string()) {
err = it->value().as_string().c_str();