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());