fix: endless loop + bit conversion logic

i'm so dumb
sorry
This commit is contained in:
DarkCat09 2025-01-10 22:34:02 +04:00
parent 3f67cb4641
commit 922f65a38f
Signed by: DarkCat09
GPG key ID: BD3CE9B65916CD82

View file

@ -155,21 +155,22 @@ pub fn parse_mac_address(input: &[u8]) -> Result<[u8; 6], Error> {
}
if !least_bit && input[idx] == b'-' {
idx += 1;
continue;
}
let bit = if (b'0'..b'9').contains(&input[idx]) {
let bit = if (b'0'..=b'9').contains(&input[idx]) {
input[idx] - b'0'
} else if (b'A'..b'F').contains(&input[idx]) {
input[idx] - b'A'
} else if (b'a'..b'f').contains(&input[idx]) {
input[idx] - b'a'
} else if (b'A'..=b'F').contains(&input[idx]) {
input[idx] - b'A' + 10
} else if (b'a'..=b'f').contains(&input[idx]) {
input[idx] - b'a' + 10
} else {
return Err(Error::MacInvalidChar { value: input[idx] });
};
if !least_bit {
mac[cur_byte] = bit << 1;
mac[cur_byte] = bit * 16;
least_bit = true;
} else {
mac[cur_byte] |= bit;