mirror of
https://github.com/esphome/esphome.git
synced 2025-10-22 03:33:52 +01:00
[api] Add message size limits to prevent memory exhaustion (#10936)
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user