mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
[vbus][rf_bridge][sensirion_common] Add buffer size guards (#14597)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d55fe9a34b
commit
9fea8fe01b
@@ -145,6 +145,9 @@ void RFBridgeComponent::loop() {
|
||||
}
|
||||
avail -= to_read;
|
||||
for (size_t i = 0; i < to_read; i++) {
|
||||
if (this->rx_buffer_.size() > MAX_RX_BUFFER_SIZE) {
|
||||
this->rx_buffer_.clear();
|
||||
}
|
||||
if (this->parse_bridge_byte_(buf[i])) {
|
||||
ESP_LOGVV(TAG, "Parsed: 0x%02X", buf[i]);
|
||||
this->last_bridge_byte_ = now;
|
||||
|
||||
@@ -30,6 +30,7 @@ static const uint8_t RF_CODE_RFIN_BUCKET = 0xB1;
|
||||
static const uint8_t RF_CODE_BEEP = 0xC0;
|
||||
static const uint8_t RF_CODE_STOP = 0x55;
|
||||
static const uint8_t RF_DEBOUNCE = 200;
|
||||
static const size_t MAX_RX_BUFFER_SIZE = 512;
|
||||
|
||||
struct RFBridgeData {
|
||||
uint16_t sync;
|
||||
|
||||
@@ -12,7 +12,7 @@ static const char *const TAG = "sensirion_i2c";
|
||||
static const size_t BUFFER_STACK_SIZE = 16;
|
||||
|
||||
bool SensirionI2CDevice::read_data(uint16_t *data, const uint8_t len) {
|
||||
const uint8_t num_bytes = len * 3;
|
||||
const size_t num_bytes = len * 3;
|
||||
uint8_t buf[num_bytes];
|
||||
|
||||
this->last_error_ = this->read(buf, num_bytes);
|
||||
|
||||
@@ -87,6 +87,9 @@ void VBus::loop() {
|
||||
this->state_ = 0;
|
||||
ESP_LOGD(TAG, "P1 empty message");
|
||||
}
|
||||
} else if (this->buffer_.size() > 15) {
|
||||
ESP_LOGW(TAG, "Unknown protocol 0x%02x, discarding", this->protocol_);
|
||||
this->state_ = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user