[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:
Jonathan Swoboda
2026-03-06 07:18:28 -05:00
committed by GitHub
parent a2c0d70c2c
commit 666fb7cf39
3 changed files with 9 additions and 1 deletions
+2
View File
@@ -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);
+2 -1
View File
@@ -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;
+5
View File
@@ -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();