mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 16:24:38 +00:00
raw: refuse an understated DNG strip whose ActiveArea reaches below the image (#2040)
decode drops such an ActiveArea for the whole image, so nothing would explain the short byte count.
This commit is contained in:
1 parent
60f7c5d74f
commit
786c5571f0
2 files changed
+3
-1
No files matched your search
@@ -546,7 +546,7 @@ fn extend_understated_strip(bytes: &[u8], info: &mut ImageInfo, raw: &Ifd) {
|
||||
}
|
||||
let ([offset], [count]) = (&info.offsets[..], &info.byte_counts[..]) else { return };
|
||||
let Some([top, left, bottom, right]) = raw.u64s(t::ACTIVE_AREA).and_then(|a| <[u64; 4]>::try_from(a).ok()) else { return };
|
||||
if left != 0 || bottom <= top || right == 0 || right >= u64::from(info.width) {
|
||||
if left != 0 || bottom <= top || bottom > u64::from(info.height) || right == 0 || right >= u64::from(info.width) {
|
||||
return;
|
||||
}
|
||||
let row_bytes = |width: u64| width.checked_mul(u64::from(info.height))?.checked_mul(bits / 8);
|
||||
|
||||
@@ -170,6 +170,8 @@ fn other_short_strips_are_still_refused() {
|
||||
assert!(refused(understated_strip_dng(8, 4, 6 * 4 * 2, None)));
|
||||
// the count is not exactly the area's bytes
|
||||
assert!(refused(understated_strip_dng(8, 4, 5 * 4 * 2, Some([0, 0, 4, 6]))));
|
||||
// the area reaches below the image, so decode would discard it
|
||||
assert!(refused(understated_strip_dng(8, 4, 6 * 4 * 2, Some([4, 0, 5, 6]))));
|
||||
// the area does not start at column 0
|
||||
assert!(refused(understated_strip_dng(8, 4, 6 * 4 * 2, Some([0, 2, 4, 8]))));
|
||||
// the file does not hold the whole raster
|
||||
|
||||
Reference in new issue
Block a user