Skip to content

Commit 9970a07

Browse files
committed
update authentication frame parsing
1 parent 79e332b commit 9970a07

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

libs/libwifi/src/parsers/frame_types/management.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,25 @@ pub fn parse_authentication_frame(
5151
let (input, auth_seq) = le_u16(input)?;
5252
let (input, status_code) = le_u16(input)?;
5353

54+
let mut challenge_text = None;
55+
let mut station_info = None;
56+
5457
// Parse the optional challenge text, if present
55-
let (challenge_text, station_info) = if auth_algorithm == 1 {
56-
let (_, challenge_text) = if input.is_empty() {
57-
(input, None)
58-
} else {
58+
if auth_algorithm == 1 && (auth_seq == 2 || auth_seq == 3) {
59+
// Parse the optional challenge text
60+
if !input.is_empty() {
5961
let (input, length) = le_u16(input)?;
60-
let (input, text) = take(length)(input)?;
61-
(input, Some(text.to_vec()))
62+
let (_input, text) = take(length)(input)?;
63+
challenge_text = Some(text.to_vec());
6264
};
63-
(challenge_text, None)
6465
} else {
6566
// Parse station info (extended capabilities) if present
66-
let station_info = if input.is_empty() {
67-
None
68-
} else if let Ok((_, info)) = parse_station_info(input) {
69-
Some(info)
70-
} else {
71-
None
72-
};
73-
(None, station_info)
74-
};
67+
if !input.is_empty() {
68+
if let Ok((_input, info)) = parse_station_info(input) {
69+
station_info = Some(info);
70+
}
71+
}
72+
}
7573

7674
Ok(Frame::Authentication(Authentication {
7775
header,

0 commit comments

Comments
 (0)