fix: endless loop + bit conversion logic
i'm so dumb sorry
This commit is contained in:
parent
3f67cb4641
commit
922f65a38f
1 changed files with 7 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue