From 37299237cb9664b1c45a48034b0efeca3ac0bbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Quentin?= Date: Tue, 16 Jul 2024 15:46:22 +0200 Subject: [PATCH] esp-wifi: Check no password given for AuthMethod::None (#1806) * esp-wifi: Check no password given for AuthMethod::None * CHANGELOG.md --- esp-wifi/CHANGELOG.md | 1 + esp-wifi/src/wifi/mod.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/esp-wifi/CHANGELOG.md b/esp-wifi/CHANGELOG.md index 16d89bc1b79..deb43fbfc13 100644 --- a/esp-wifi/CHANGELOG.md +++ b/esp-wifi/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed +- Check no password is set when using `AuthMethod::None`(#1806) ### Fixed diff --git a/esp-wifi/src/wifi/mod.rs b/esp-wifi/src/wifi/mod.rs index 53d49335568..762dd736e18 100644 --- a/esp-wifi/src/wifi/mod.rs +++ b/esp-wifi/src/wifi/mod.rs @@ -2074,6 +2074,12 @@ fn apply_ap_config(config: &AccessPointConfiguration) -> Result<(), WifiError> { }, }; + if config.auth_method == AuthMethod::None && !config.password.is_empty() { + return Err(WifiError::InternalError( + InternalWifiError::EspErrInvalidArg, + )); + } + unsafe { cfg.ap.ssid[0..(config.ssid.len())].copy_from_slice(config.ssid.as_bytes()); cfg.ap.ssid_len = config.ssid.len() as u8; @@ -2113,6 +2119,12 @@ fn apply_sta_config(config: &ClientConfiguration) -> Result<(), WifiError> { }, }; + if config.auth_method == AuthMethod::None && !config.password.is_empty() { + return Err(WifiError::InternalError( + InternalWifiError::EspErrInvalidArg, + )); + } + unsafe { cfg.sta.ssid[0..(config.ssid.len())].copy_from_slice(config.ssid.as_bytes()); cfg.sta.password[0..(config.password.len())].copy_from_slice(config.password.as_bytes());