From ebe3545c8d4128a094b52eaebe86a38de44962eb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 31 Mar 2022 20:09:35 +0100 Subject: [PATCH] parse_slice_hex: Fix to properly handle odd-length slices Previously it would accept some of them, and parse them in a weird way. I don't think this is actually important. Signed-off-by: Ian Jackson --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 310d0772..cfaafb37 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -716,7 +716,7 @@ pub fn fmt_hex(f: &mut Formatter, buf: &[u8]) { #[must_use] pub fn parse_slice_hex(s: &str, buf: &mut [u8]) -> usize { let l = s.len(); - if l % 1 != 0 { throw!() } + if l % 2 != 0 { throw!() } let l = l/2; if l > buf.len() { throw!() } -- 2.30.2