From 922f65a38f3683f1efe77caed8e3079903a4b56c Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 10 Jan 2025 22:34:02 +0400 Subject: [PATCH] fix: endless loop + bit conversion logic i'm so dumb sorry --- src/ingest_protocol/parser.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ingest_protocol/parser.rs b/src/ingest_protocol/parser.rs index 3c8e010..ce1bc3c 100644 --- a/src/ingest_protocol/parser.rs +++ b/src/ingest_protocol/parser.rs @@ -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;