From eac9941766b04036544fd821b8f5e77f37657539 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 19 Feb 2023 09:42:21 -0500 Subject: [PATCH] LibGfx: Make NamedColor2TagData verify inputs are 32-byte 7-bit ASCII NamedColor2TagData::from_bytes() errors out if that isn't the case, but let's make sure other potential future callers get it right too. --- Userland/Libraries/LibGfx/ICC/TagTypes.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.h b/Userland/Libraries/LibGfx/ICC/TagTypes.h index 7ee6149592..febecfee6e 100644 --- a/Userland/Libraries/LibGfx/ICC/TagTypes.h +++ b/Userland/Libraries/LibGfx/ICC/TagTypes.h @@ -537,6 +537,20 @@ public: { VERIFY(root_names.size() == pcs_coordinates.size()); VERIFY(root_names.size() * number_of_device_coordinates == device_coordinates.size()); + + for (u8 byte : m_prefix.bytes()) + VERIFY(byte < 128); + VERIFY(m_prefix.bytes().size() < 32); + + for (u8 byte : m_suffix.bytes()) + VERIFY(byte < 128); + VERIFY(m_suffix.bytes().size() < 32); + + for (auto const& root_name : m_root_names) { + for (u8 byte : root_name.bytes()) + VERIFY(byte < 128); + VERIFY(root_name.bytes().size() < 32); + } } // "(least-significant 16 bits reserved for ICC use)"