Skip to content

Commit

Permalink
esp-wifi: Check no password given for AuthMethod::None (#1806)
Browse files Browse the repository at this point in the history
* esp-wifi: Check no password given for AuthMethod::None

* CHANGELOG.md
  • Loading branch information
bjoernQ authored Jul 16, 2024
1 parent 04cad71 commit 3729923
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions esp-wifi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 3729923

Please sign in to comment.