Fix decoder panic with malformed (empty) sample format tag
I've included a minimal reproducer in tests/fuzz_images/oor_panic/sample-format-empty-vec.bin
This commit is contained in:
1 parent
4adba46b9f
commit
714e470595
3 files changed
+8
-10
No files matched your search
@@ -145,12 +145,15 @@ impl Image {
|
||||
.map(SampleFormat::from_u16_exhaustive)
|
||||
.collect();
|
||||
|
||||
let Some(format) = sample_format.first().copied() else {
|
||||
// Reject empty sample formats
|
||||
return Err(TiffFormatError::InvalidTagValueType(Tag::SampleFormat).into());
|
||||
};
|
||||
// TODO: for now, only homogenous formats across samples are supported.
|
||||
if !sample_format.windows(2).all(|s| s[0] == s[1]) {
|
||||
if !sample_format.iter().all(|&s| s == format) {
|
||||
return Err(TiffUnsupportedError::UnsupportedSampleFormat(sample_format).into());
|
||||
}
|
||||
|
||||
sample_format[0]
|
||||
format
|
||||
}
|
||||
None => SampleFormat::Uint,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user