mirror of
https://github.com/esphome/esphome.git
synced 2026-08-17 02:47:52 +08:00
[ld2420] Fix out-of-bounds read when device reports unknown command error (#18322)
This commit is contained in:
@@ -746,7 +746,14 @@ void LD2420Component::set_reg_value(uint16_t reg, uint16_t value) {
|
||||
this->send_cmd_from_array(cmd_frame);
|
||||
}
|
||||
|
||||
void LD2420Component::handle_cmd_error(uint8_t error) { ESP_LOGE(TAG, "Command failed: %s", ERR_MESSAGE[error]); }
|
||||
void LD2420Component::handle_cmd_error(uint16_t error) {
|
||||
if (error < std::size(ERR_MESSAGE)) {
|
||||
ESP_LOGE(TAG, "Command failed: %s", ERR_MESSAGE[error]);
|
||||
} else {
|
||||
// The error word comes from the device reply frame; unknown codes must not index ERR_MESSAGE
|
||||
ESP_LOGE(TAG, "Command failed: error 0x%04X", error);
|
||||
}
|
||||
}
|
||||
|
||||
int LD2420Component::get_gate_threshold_(uint8_t gate) {
|
||||
uint8_t error;
|
||||
|
||||
@@ -108,7 +108,7 @@ class LD2420Component final : public Component, public uart::UARTDevice {
|
||||
float get_setup_priority() const override;
|
||||
int send_cmd_from_array(CmdFrameT cmd_frame);
|
||||
void report_gate_data();
|
||||
void handle_cmd_error(uint8_t error);
|
||||
void handle_cmd_error(uint16_t error);
|
||||
void set_operating_mode(const char *state);
|
||||
void auto_calibrate_sensitivity();
|
||||
void update_radar_data(uint16_t const *gate_energy, uint8_t sample_number);
|
||||
|
||||
Reference in New Issue
Block a user