ICC: all built-in profiles are checked for aligned sizes and tags

The #1584 regression covered the four built-in RGB spaces. It now also
checks gray and both CMYK profiles: header size equal to the length, a
length that is a multiple of 4, tag offsets on 4-byte boundaries, tag
data within the profile, and that the profile still parses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
KnottyDyes
2026-10-21 23:14:28 +07:00
committed by bflatastic
co-authored by Claude Opus 5.5
parent bc6ffd9c1e
commit bc3351eacc
+4 -4
View File
@@ -113,11 +113,11 @@ fn black_point_compensation_maps_the_darkest_ink_to_rgb_black() {
assert_eq!(abs(true), abs(false));
}
/// #1584: the profiles written here (built-in RGB spaces) have every tag on a 4-byte boundary and
/// a size that is a multiple of 4 (ICC.1 §7.1.2), and still read back as the same space.
/// #1584: every built-in profile (RGB, CMYK and gray) has each tag on a 4-byte boundary and a size
/// that is a multiple of 4 (ICC.1 §7.1.2), and still reads back as the same space.
#[test]
fn written_profiles_align_their_tags() {
for name in [super::SRGB, super::DISPLAY_P3, super::WIDE_GAMUT_RGB, super::PROPHOTO_RGB] {
fn builtin_profiles_align_their_sizes_and_tags() {
for name in BUILTIN_RGB.into_iter().chain(BUILTIN_CMYK).chain([GRAY]) {
let icc = super::icc_bytes(name).unwrap();
let be = |at: usize| u32::from_be_bytes([icc[at], icc[at + 1], icc[at + 2], icc[at + 3]]) as usize;
assert_eq!(be(0), icc.len(), "{name}: header size");