Fix out of bounds subtraction with invalid JPEG table

This commit is contained in:
5225225 committed 2021-05-29 22:12:35 +01:00
1 parent 5b7814c994
commit 03b6ed413b
3 files changed
+43 -1

No files matched your search

+11 -1
View File
@@ -1372,7 +1372,17 @@ impl<R: Read + Seek> Decoder<R> {
let jpeg_tables: Option<Vec<u8>> = match self.find_tag(Tag::JPEGTables) {
Ok(None) => None,
Ok(_) => Some(self.get_tag_u8_vec(Tag::JPEGTables)?),
Ok(_) => {
let vec = self.get_tag_u8_vec(Tag::JPEGTables)?;
if vec.len() < 2 {
return Err(TiffError::FormatError(
TiffFormatError::InvalidTagValueType(Tag::JPEGTables),
));
}
Some(vec)
}
Err(e) => return Err(e),
};