summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-02-26 10:22:10 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-01 15:51:24 +0000
commit90e9974f1596cb6fd9cf15ddf9e34d15a387bb7b (patch)
tree65bc20e2c62e81c160f88d884df10073fe09b38c /src/gui
parentb4ee126a75e0f6f23ba9401352f30d5af8f4eccb (diff)
Handle desc tags the same way for OOB checks as the other tags
Including one entry of the value in the header is pointless after the unaligned access rewrite, and a potentially dangerous pattern, though safe here due to overchecking. Pick-to: 6.1 Change-Id: I4c0380040f89920467c309503408f1df6f88423f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qicc.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/gui/painting/qicc.cpp b/src/gui/painting/qicc.cpp
index 09ac40b50e..4be339b299 100644
--- a/src/gui/painting/qicc.cpp
+++ b/src/gui/painting/qicc.cpp
@@ -176,7 +176,7 @@ struct ParaTagData : GenericTagData {
struct DescTagData : GenericTagData {
quint32_be asciiDescriptionLength;
- char asciiDescription[1];
+ // followed by ascii description: char[]
// .. we ignore the rest
};
@@ -599,18 +599,14 @@ bool parseDesc(const QByteArray &data, const TagEntry &tagEntry, QString &descNa
// Either 'desc' (ICCv2) or 'mluc' (ICCv4)
if (tag.type == quint32(Tag::desc)) {
- if (tagEntry.size < sizeof(DescTagData))
- return false;
+ Q_STATIC_ASSERT(sizeof(DescTagData) == 12);
const DescTagData desc = qFromUnaligned<DescTagData>(data.constData() + tagEntry.offset);
const quint32 len = desc.asciiDescriptionLength;
if (len < 1)
return false;
if (tagEntry.size - 12 < len)
return false;
- static_assert(sizeof(GenericTagData) == 2 * sizeof(quint32_be),
- "GenericTagData has padding. The following code is a subject to UB.");
- const char *asciiDescription = data.constData() + tagEntry.offset + sizeof(GenericTagData)
- + sizeof(quint32_be);
+ const char *asciiDescription = data.constData() + tagEntry.offset + sizeof(DescTagData);
if (asciiDescription[len - 1] != '\0')
return false;
descName = QString::fromLatin1(asciiDescription, len - 1);