1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-13 22:28:14 +00:00

fix: use reinterpret_cast for safe string copy in add_lamp function of DynamicLampComponent

This commit is contained in:
Oliver Kleinecke 2025-02-20 00:02:20 +01:00
parent a965b87abb
commit 6cb00a8466

View File

@ -137,7 +137,7 @@ void DynamicLampComponent::add_available_output(output::FloatOutput * output, st
void DynamicLampComponent::add_lamp(std::string name) {
if (this->lamp_count_ < 15) {
this->active_lamps_[this->lamp_count_].active = true;
strncpy(static_cast<char *>(this->active_lamps_[this->lamp_count_].name), name.c_str(), 16);
strncpy(reinterpret_cast<char*>(this->active_lamps_[this->lamp_count_].name), name.c_str(), 16);
this->active_lamps_[this->lamp_count_].validation_byte = 'L';
this->active_lamps_[this->lamp_count_].lamp_index = this->lamp_count_;
this->active_lamps_[this->lamp_count_].used_outputs[0] = 0;