esp-wifi: Check no password given for AuthMethod::None (#1806)

* esp-wifi: Check no password given for AuthMethod::None

* CHANGELOG.md
This commit is contained in:
Björn Quentin 2024-07-16 15:46:22 +02:00 committed by GitHub
parent 04cad71926
commit 37299237cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

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