[api] Add message size limits to prevent memory exhaustion (#10936)

This commit is contained in:
J. Nick Koston
2025-10-08 00:47:31 +00:00
committed by GitHub
parent 7682b4e9a3
commit 5aff20a624
4 changed files with 35 additions and 21 deletions
@@ -115,10 +115,10 @@ APIError APIPlaintextFrameHelper::try_read_frame_() {
continue;
}
if (msg_size_varint->as_uint32() > std::numeric_limits<uint16_t>::max()) {
if (msg_size_varint->as_uint32() > MAX_MESSAGE_SIZE) {
state_ = State::FAILED;
HELPER_LOG("Bad packet: message size %" PRIu32 " exceeds maximum %u", msg_size_varint->as_uint32(),
std::numeric_limits<uint16_t>::max());
MAX_MESSAGE_SIZE);
return APIError::BAD_DATA_PACKET;
}
rx_header_parsed_len_ = msg_size_varint->as_uint16();