From e875c7da44a72d49d05a9a0707157605cd52f693 Mon Sep 17 00:00:00 2001 From: Nathan Fiedler Date: Wed, 27 May 2020 18:29:41 -0700 Subject: [PATCH] Skip over unknown boxes (#4) * Skip over unknown boxes If the box size is non-zero, skip over it and continue reading. Otherwise if the box size is zero, exit the loop. * Add comment clarifying the box skipping --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d5286ec..bf9ea55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,15 @@ fn read_boxes(f: File) -> Result { BoxType::MoofBox => { start = (size as u32 - HEADER_SIZE) as u64; } - _ => break + _ => { + // Skip over unsupported boxes, but stop if the size is zero, + // meaning the last box has been reached. + if size == 0 { + break; + } else { + start = (size as u32 - HEADER_SIZE) as u64; + } + } }; } Ok(bmff)