From c130213d2ea9ecaacc0a08ff95ba8b969c6ee329 Mon Sep 17 00:00:00 2001 From: Sachin Saini Date: Sat, 5 Nov 2022 20:22:37 +0530 Subject: [PATCH] fix: fix incorrect handling of map length while parsing map frames --- src/frame.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/frame.rs b/src/frame.rs index 87223e6..4e96f5e 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -145,9 +145,6 @@ fn parse_null(line: &[u8]) -> Result { fn parse_map(buf: &mut Cursor<&[u8]>, line: &[u8]) -> Result { let len = atoi::(line).ok_or(ParseFrameError::InvalidFormat)?; - if len % 2 != 0 { - return Err(ParseFrameError::InvalidFormat); - } let mut map = Vec::with_capacity(2 * len); for _ in 0..len { let key = parse(buf)?; @@ -533,12 +530,6 @@ mod tests { assert_eq!(parse(&mut buf), Err(ParseFrameError::InvalidFormat)) } - #[test] - fn parse_given_map_with_odd_length_return_invalid_format_error() { - let mut buf = get_cursor_from_bytes(b"#1\r\n$3\r\nfoo\r\n"); - assert_eq!(parse(&mut buf), Err(ParseFrameError::InvalidFormat)) - } - #[test] fn parse_given_incomplete_map_return_incomplete_error() { let mut buf = get_cursor_from_bytes(b"#2\r\n$3\r\nfoo\r\n");