mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 15:10:51 +00:00
[esp32_improv][rf_bridge][esp32_ble_server][display][lvgl][pipsolar] Fix unsigned integer underflows (#14466)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
@@ -661,6 +661,9 @@ void Display::printf(int x, int y, BaseFont *font, const char *format, ...) {
|
||||
void Display::set_writer(display_writer_t &&writer) { this->writer_ = writer; }
|
||||
|
||||
void Display::set_pages(std::vector<DisplayPage *> pages) {
|
||||
if (pages.empty())
|
||||
return;
|
||||
|
||||
for (auto *page : pages)
|
||||
page->set_parent(this);
|
||||
|
||||
|
||||
@@ -209,7 +209,11 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt
|
||||
|
||||
esp_gatt_rsp_t response;
|
||||
if (param->read.is_long) {
|
||||
if (this->value_.size() - this->value_read_offset_ < max_offset) {
|
||||
if (this->value_read_offset_ >= this->value_.size()) {
|
||||
response.attr_value.len = 0;
|
||||
response.attr_value.offset = this->value_read_offset_;
|
||||
this->value_read_offset_ = 0;
|
||||
} else if (this->value_.size() - this->value_read_offset_ < max_offset) {
|
||||
// Last message in the chain
|
||||
response.attr_value.len = this->value_.size() - this->value_read_offset_;
|
||||
response.attr_value.offset = this->value_read_offset_;
|
||||
|
||||
@@ -314,6 +314,8 @@ void ESP32ImprovComponent::dump_config() {
|
||||
}
|
||||
|
||||
void ESP32ImprovComponent::process_incoming_data_() {
|
||||
if (this->incoming_data_.size() < 3)
|
||||
return;
|
||||
uint8_t length = this->incoming_data_[1];
|
||||
|
||||
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
|
||||
|
||||
@@ -421,7 +421,7 @@ void LvglComponent::write_random_() {
|
||||
col = col / this->draw_rounding * this->draw_rounding;
|
||||
auto row = random_uint32() % this->disp_drv_.ver_res;
|
||||
row = row / this->draw_rounding * this->draw_rounding;
|
||||
auto size = (random_uint32() % 32) / this->draw_rounding * this->draw_rounding - 1;
|
||||
auto size = ((random_uint32() % 32) / this->draw_rounding + 2) * this->draw_rounding - 1;
|
||||
lv_area_t area;
|
||||
area.x1 = col;
|
||||
area.y1 = row;
|
||||
|
||||
@@ -162,13 +162,15 @@ void Pipsolar::loop() {
|
||||
}
|
||||
|
||||
uint8_t Pipsolar::check_incoming_length_(uint8_t length) {
|
||||
if (this->read_pos_ - 3 == length) {
|
||||
if (this->read_pos_ >= 3 && this->read_pos_ - 3 == length) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Pipsolar::check_incoming_crc_() {
|
||||
if (this->read_pos_ < 3)
|
||||
return 0;
|
||||
uint16_t crc16;
|
||||
crc16 = this->pipsolar_crc_(read_buffer_, read_pos_ - 3);
|
||||
if (((uint8_t) ((crc16) >> 8)) == read_buffer_[read_pos_ - 3] &&
|
||||
|
||||
@@ -74,7 +74,7 @@ bool RFBridgeComponent::parse_bridge_byte_(uint8_t byte) {
|
||||
data.length = raw[2];
|
||||
data.protocol = raw[3];
|
||||
char next_byte[3]; // 2 hex chars + null
|
||||
for (uint8_t i = 0; i < data.length - 1; i++) {
|
||||
for (uint8_t i = 0; i + 1 < data.length; i++) {
|
||||
buf_append_printf(next_byte, sizeof(next_byte), 0, "%02X", raw[4 + i]);
|
||||
data.code += next_byte;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user