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

fix: use strncpy instead of memcpy for safe string copy in add_lamp function of DynamicLampComponent

This commit is contained in:
Oliver Kleinecke 2025-02-19 23:55:51 +01:00
parent 857eeb93e8
commit 9366a92354

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;
memcpy(this->active_lamps_[this->lamp_count_].name, name.c_str(), 16);
strncpy(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;