LibGfx: Verify ICC reserved header bytes are zero
I checked that they are zero for all profiles in Compact-ICC-Profiles and for all .icc files in /Library/ColorSync and /System/Library/ColorSync on my Mac (running macOS 12.6.2).
This commit is contained in:
parent
090bd02a88
commit
b0068c387b
Notes:
sideshowbarker
2024-07-17 06:45:52 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/b0068c387b Pull-request: https://github.com/SerenityOS/serenity/pull/16863 Reviewed-by: https://github.com/linusg
1 changed files with 10 additions and 0 deletions
|
@ -259,6 +259,15 @@ Optional<Crypto::Hash::MD5::DigestType> parse_profile_id(ICCHeader const& header
|
|||
|
||||
return md5;
|
||||
}
|
||||
|
||||
ErrorOr<void> parse_reserved(ICCHeader const& header)
|
||||
{
|
||||
// ICC v4, 7.2.19 Reserved field
|
||||
// "This field of the profile header is reserved for future ICC definition and shall be set to zero."
|
||||
if (!all_bytes_are_zero(header.reserved))
|
||||
return Error::from_string_literal("ICC::Profile: Reserved header bytes are not zero");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
StringView device_class_name(DeviceClass device_class)
|
||||
|
@ -391,6 +400,7 @@ ErrorOr<NonnullRefPtr<Profile>> Profile::try_load_from_externally_owned_memory(R
|
|||
profile->m_rendering_intent = TRY(parse_rendering_intent(header));
|
||||
profile->m_pcs_illuminant = TRY(parse_pcs_illuminant(header));
|
||||
profile->m_id = parse_profile_id(header);
|
||||
TRY(parse_reserved(header));
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue