From: Ian Jackson Date: Thu, 31 Mar 2022 19:09:35 +0000 (+0100) Subject: parse_slice_hex: Fix to properly handle odd-length slices X-Git-Tag: otter-1.0.0~33 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ebe3545c8d4128a094b52eaebe86a38de44962eb;p=otter.git 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 --- 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!() }