fix(libmsg): complete security audit round 2 - fix P0 race + harden input validation
- P0: fix _close_all_clients() race condition (CWE-362) - hold per-connection send_lock before close() to prevent messages being sent to wrong client after fd reuse - P2: add comprehensive input validation for all public APIs (timeout/port/workers/max_connections/batch_size etc. bounds checking) - P2: add UTF-8 payload validation (isValidUtf8) aligning with Python pymsg behavior, rejecting overlong encodings, surrogate pairs, truncated/invalid sequences - P2: document pmsg_recv(int) precondition and recommend deadline mode - add constructor validation for MsgClient/MsgServer/AsyncQueue/RpcClient/RpcServer - add add_route() validation for empty route name and null handler - update security audit report with round 2 findings and fixes (8 issues total, 100% fixed)
This commit is contained in:
1 parent
9256a8157b
commit
3c50a862d3
6 files changed
+351
-76
No files matched your search
@@ -74,7 +74,14 @@ public:
|
||||
: _addr(addr), _port(port), _name(name),
|
||||
_timeout(timeout),
|
||||
_retry_on_refused(retry_on_refused),
|
||||
_retry_interval(retry_interval) {}
|
||||
_retry_interval(retry_interval) {
|
||||
if (timeout <= 0 || timeout > 300.0) {
|
||||
throw MsgException("invalid timeout: " + std::to_string(timeout));
|
||||
}
|
||||
if (retry_interval <= 0 || retry_interval > 60.0) {
|
||||
throw MsgException("invalid retry_interval: " + std::to_string(retry_interval));
|
||||
}
|
||||
}
|
||||
|
||||
// ---- RPC 调用 ----------------------------------------------------------
|
||||
|
||||
|
||||
Reference in new issue
Block a user