diff --git a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp index 9bea573dce..38ebbc90e4 100644 --- a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp +++ b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp @@ -8,8 +8,8 @@ namespace gpio { static const char *const TAG = "gpio.binary_sensor"; #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG -// Interrupt type strings indexed by InterruptType enum (1-3): RISING_EDGE, FALLING_EDGE, ANY_EDGE -// Index 0 is a placeholder (no enum value 0), also used as fallback for out-of-range +// Interrupt type strings indexed by edge-triggered InterruptType values: +// indices 1-3: RISING_EDGE, FALLING_EDGE, ANY_EDGE; other values (e.g. level-triggered) map to UNKNOWN (index 0). PROGMEM_STRING_TABLE(InterruptTypeStrings, "UNKNOWN", "RISING_EDGE", "FALLING_EDGE", "ANY_EDGE"); static const LogString *interrupt_type_to_string(gpio::InterruptType type) { diff --git a/esphome/components/update/update_entity.cpp b/esphome/components/update/update_entity.cpp index c80609e7ed..7edea2fe22 100644 --- a/esphome/components/update/update_entity.cpp +++ b/esphome/components/update/update_entity.cpp @@ -13,7 +13,8 @@ static const char *const TAG = "update"; PROGMEM_STRING_TABLE(UpdateStateStrings, "UNKNOWN", "NO UPDATE", "UPDATE AVAILABLE", "INSTALLING"); const LogString *update_state_to_string(UpdateState state) { - return UpdateStateStrings::get_log_str(static_cast(state), 0); + return UpdateStateStrings::get_log_str(static_cast(state), + static_cast(UpdateState::UPDATE_STATE_UNKNOWN)); } void UpdateEntity::publish_state() { diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index 3eaed47c33..4f7982178f 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -743,9 +743,7 @@ class WiFiComponent : public Component { #if USE_NETWORK_IPV6 uint8_t num_ipv6_addresses_{0}; #endif /* USE_NETWORK_IPV6 */ - // 0 = no error, non-zero = disconnect reason code from callback - // This serves as both the error flag and stores the reason for deferred logging - uint8_t error_from_callback_{0}; + bool error_from_callback_{false}; RetryHiddenMode retry_hidden_mode_{RetryHiddenMode::BLIND_RETRY}; RoamingState roaming_state_{RoamingState::IDLE}; #if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE) diff --git a/esphome/components/wifi/wifi_component_esp8266.cpp b/esphome/components/wifi/wifi_component_esp8266.cpp index 3257f40320..db2fae660b 100644 --- a/esphome/components/wifi/wifi_component_esp8266.cpp +++ b/esphome/components/wifi/wifi_component_esp8266.cpp @@ -43,10 +43,6 @@ namespace esphome::wifi { static const char *const TAG = "wifi_esp8266"; -/// Special disconnect reason for authmode downgrade (CVE-2020-12638 mitigation) -/// Not a real WiFi reason code - used internally for deferred logging -static constexpr uint8_t WIFI_DISCONNECT_REASON_AUTHMODE_DOWNGRADE = 254; - static bool s_sta_connected = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) static bool s_sta_got_ip = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) static bool s_sta_connect_not_found = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) @@ -518,8 +514,7 @@ void WiFiComponent::wifi_event_callback(System_Event_t *event) { } s_sta_connected = false; s_sta_connecting = false; - // Store reason as error flag; defer listener callbacks to main loop - global_wifi_component->error_from_callback_ = it.reason; + global_wifi_component->error_from_callback_ = true; #ifdef USE_WIFI_CONNECT_STATE_LISTENERS global_wifi_component->pending_.disconnect = true; #endif @@ -534,7 +529,7 @@ void WiFiComponent::wifi_event_callback(System_Event_t *event) { if (it.old_mode != AUTH_OPEN && it.new_mode == AUTH_OPEN) { ESP_LOGW(TAG, "Potential Authmode downgrade detected, disconnecting"); wifi_station_disconnect(); - global_wifi_component->error_from_callback_ = WIFI_DISCONNECT_REASON_AUTHMODE_DOWNGRADE; + global_wifi_component->error_from_callback_ = true; } break; }