diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8e1efa6f..c6575d59 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -28,5 +28,6 @@ geckoxx [https://github.com/geckoxx] Herohtar [https://github.com/herohtar] nicholaswyoung [https://github.com/nicholaswyoung] richardmitic [https://github.com/richardmitic] +sscobici [https://github.com/sscobici] terrorfisch [https://github.com/terrorfisch] Tommoa [https://github.com/Tommoa] \ No newline at end of file diff --git a/symphonia-metadata/src/utils/images.rs b/symphonia-metadata/src/utils/images.rs index 34a4cffb..a70611bb 100644 --- a/symphonia-metadata/src/utils/images.rs +++ b/symphonia-metadata/src/utils/images.rs @@ -64,7 +64,16 @@ pub fn try_get_image_info(buf: &[u8]) -> Option { fn parse_jpeg(mut reader: BufReader<'_>) -> Result { while reader.read_u8()? == 0xff { let chunk_type = reader.read_u8()?; + + // Skip parameter-less markers, see https://github.com/corkami/formats/blob/master/image/jpeg.md + if chunk_type >= 0xd0 && chunk_type <= 0xd9 { + continue; + } + let chunk_len = reader.read_be_u16()?; + if chunk_len < 2 { + return decode_error("meta (jpeg): invalid chunk length"); + } // Baseline, and progressive DCT. if chunk_type == 0xc0 || chunk_type == 0xc2 {