Add check for an invalid strip count

This commit is contained in:
5225225 committed 2021-05-29 12:36:50 +01:00
1 parent 2f4e491874
commit 1e10b9803b
2 files changed
+27 -1

No files matched your search

+7 -1
View File
@@ -1277,7 +1277,13 @@ impl<R: Read + Seek> Decoder<R> {
return Ok(0);
}
Ok((self.height + rows_per_strip - 1) / rows_per_strip)
// rows_per_strip - 1 can never fail since we know it's at least 1
let height = match self.height.checked_add(rows_per_strip - 1) {
Some(h) => h,
None => return Err(TiffError::IntSizeError),
};
Ok(height / rows_per_strip)
}
/// Number of tiles in image