diff --git a/esphome/components/ld2415h/ld2415h.cpp b/esphome/components/ld2415h/ld2415h.cpp index 4985432d9d..5b21b1d676 100644 --- a/esphome/components/ld2415h/ld2415h.cpp +++ b/esphome/components/ld2415h/ld2415h.cpp @@ -291,7 +291,7 @@ void LD2415HComponent::parse_firmware_() { ++fw; // Copy string into firmware - std::strcpy(this->firmware_, fw); + std::strncpy(this->firmware_, fw, sizeof(this->firmware_)); } else { ESP_LOGE(TAG, "Firmware value invalid."); }