Validate that images contain the proper number of strips (#174)

This commit is contained in:
Jonathan Behrens authored and GitHub committed 2022-09-04 12:00:34 -07:00
1 parent 2ec1ab7489
commit bd23428f52
3 files changed
+11 -28

No files matched your search

+5 -1
View File
@@ -208,7 +208,11 @@ impl Image {
strip_decoder = Some(StripDecodeState { rows_per_strip });
tile_attributes = None;
if chunk_offsets.len() != chunk_bytes.len() {
if chunk_offsets.len() != chunk_bytes.len()
|| rows_per_strip == 0
|| u32::try_from(chunk_offsets.len())?
!= height.saturating_sub(1) / rows_per_strip + 1
{
return Err(TiffError::FormatError(
TiffFormatError::InconsistentSizesEncountered,
));