From 98b1f29c6a92a729a70d7bb241383f37213c8bf2 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Tue, 18 Feb 2025 13:26:26 +0100 Subject: [PATCH] fix: correct string copy function and update FRAM write calls in add_timer method --- esphome/components/dynamic_lamp/dynamic_lamp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.cpp b/esphome/components/dynamic_lamp/dynamic_lamp.cpp index 9f110a3ec5..31669b126d 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.cpp +++ b/esphome/components/dynamic_lamp/dynamic_lamp.cpp @@ -232,7 +232,7 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u bool friday, bool saturday, bool sunday) { //unsigned char* lamp_name_cstr = lamp_name.c_str(); unsigned char lamp_name_buffer[32]; - strncopy(lamp_name_buffer, lamp_name.data(), 32); + strncpy(lamp_name_buffer, lamp_name.data(), 32); DynamicLampTimer new_timer; new_timer.active = timer_active; new_timer.mode = mode; @@ -255,8 +255,8 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u lamp_name.c_str(), new_timer.active, new_timer.mode, new_timer.hour, new_timer.minute, new_timer.monday, new_timer.tuesday, new_timer.wednesday, new_timer.thursday, new_timer.friday, new_timer.saturday, new_timer.sunday); ESP_LOGV(TAG, "Size of struct is %" PRIu8 "", static_cast(sizeof(new_timer))); - this->fram_->write(2048, &lamp_name_buffer, 32); - this->fram_->writeObject((2048 + 32), new_timer); + this->fram_->write(2048, lamp_name_buffer, 32); + this->fram_->write((2048 + 32), new_timer, 24); return true; }