From 4687e58b03001e4a91eed244b402449544545667 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 4 Oct 2025 22:02:32 -0500 Subject: [PATCH] help bot --- esphome/components/wifi/wifi_component.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index fa33d4033f..42ba4a961b 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -316,9 +316,9 @@ void WiFiComponent::set_sta(const WiFiAP &ap) { } void WiFiComponent::clear_sta() { this->sta_.clear(); } void WiFiComponent::save_wifi_sta(const std::string &ssid, const std::string &password) { - SavedWifiSettings save{}; // zero-initialized - strncpy(save.ssid, ssid.c_str(), sizeof(save.ssid) - 1); - strncpy(save.password, password.c_str(), sizeof(save.password) - 1); + SavedWifiSettings save{}; // zero-initialized - all bytes set to \0, guaranteeing null termination + strncpy(save.ssid, ssid.c_str(), sizeof(save.ssid) - 1); // max 32 chars, byte 32 remains \0 + strncpy(save.password, password.c_str(), sizeof(save.password) - 1); // max 64 chars, byte 64 remains \0 this->pref_.save(&save); // ensure it's written immediately global_preferences->sync();