From 4eaa28790548f9155eb3bb8299c7715bc47d5905 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Thu, 15 Jul 2021 10:35:04 -0400 Subject: [PATCH] Don't crash on unknown record flag bits --- src/parser.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index f56a2a7..712adc8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -357,9 +357,9 @@ fn parse_record_header(input: &[u8]) -> IResult<&[u8], RecordHeader> { let (input, record_type) = verify(parse_4char, |record_type: &str| record_type != "GRUP")(input)?; let (input, size) = le_u32(input)?; - let (input, flags) = map_res(le_u32, |bits| { - RecordFlags::from_bits(bits).ok_or("bad record flag") - })(input)?; + let (input, flag_bits) = le_u32(input)?; + // Okay to truncate since we only care about bits we know about and don't want to crash on unknown bits. + let flags = RecordFlags::from_bits_truncate(flag_bits); let (input, id) = le_u32(input)?; let (input, timestamp) = le_u16(input)?; let (input, version_control_info) = le_u16(input)?;