summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-01-06 12:06:12 -0500
committerLinus Groh <mail@linusgroh.de>2023-01-06 19:17:22 +0100
commitb0068c387bf4005f26170964351d707c5cc90ac2 (patch)
tree3c95289a90ebc25837138e8b43d0f03d377ec92b /Userland/Libraries/LibGfx
parent090bd02a8885fbdb2b510ffd23cef3e2e31cf6ef (diff)
downloadserenity-b0068c387bf4005f26170964351d707c5cc90ac2.zip
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).
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/ICCProfile.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ICCProfile.cpp b/Userland/Libraries/LibGfx/ICCProfile.cpp
index 406a320387..c56e155833 100644
--- a/Userland/Libraries/LibGfx/ICCProfile.cpp
+++ b/Userland/Libraries/LibGfx/ICCProfile.cpp
@@ -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;
}