mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
[sx127x][sx126x][max6956] Fix null deref, unterminated string, and pin bounds check (#14529)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -111,6 +111,8 @@ void MAX6956::write_brightness_mode() {
|
||||
}
|
||||
|
||||
void MAX6956::set_pin_brightness(uint8_t pin, float brightness) {
|
||||
if (pin < MAX6956_MIN || pin > MAX6956_MAX)
|
||||
return;
|
||||
uint8_t reg_addr = MAX6956_CURRENT_START + (pin - MAX6956_MIN) / 2;
|
||||
uint8_t config = 0;
|
||||
uint8_t shift = 4 * (pin % 2);
|
||||
|
||||
@@ -155,7 +155,8 @@ void SX126x::configure() {
|
||||
}
|
||||
|
||||
// check silicon version to make sure hw is ok
|
||||
this->read_register_(REG_VERSION_STRING, (uint8_t *) this->version_, 16);
|
||||
this->read_register_(REG_VERSION_STRING, (uint8_t *) this->version_, sizeof(this->version_));
|
||||
this->version_[sizeof(this->version_) - 1] = '\0';
|
||||
if (strncmp(this->version_, "SX126", 5) != 0 && strncmp(this->version_, "LLCC68", 6) != 0) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
|
||||
@@ -260,6 +260,11 @@ SX127xError SX127x::transmit_packet(const std::vector<uint8_t> &packet) {
|
||||
return SX127xError::INVALID_PARAMS;
|
||||
}
|
||||
|
||||
if (this->dio0_pin_ == nullptr) {
|
||||
ESP_LOGE(TAG, "DIO0 pin not configured, cannot wait for transmit completion");
|
||||
return SX127xError::INVALID_PARAMS;
|
||||
}
|
||||
|
||||
SX127xError ret = SX127xError::NONE;
|
||||
if (this->modulation_ == MOD_LORA) {
|
||||
this->set_mode_standby();
|
||||
|
||||
Reference in New Issue
Block a user