Protect against sign-change of size on 32bit

Since qsizetype is signed and the profileSize unsigned, it can turn
negative circumventing the test here.

Fixes oss-fuzz issue 29278.

Pick-to: 6.0 5.15
Change-Id: I1e211c78db6f4ff150613f52d8fc29807f0088ff
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
Allan Sandfeld Jensen 2021-01-26 12:07:53 +01:00
parent a543e8f42e
commit 05741b404a
1 changed files with 1 additions and 1 deletions

View File

@ -646,7 +646,7 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
const ICCProfileHeader header = qFromUnaligned<ICCProfileHeader>(data.constData());
if (!isValidIccProfile(header))
return false; // if failed we already printing a warning
if (qsizetype(header.profileSize) > data.size()) {
if (qsizetype(header.profileSize) > data.size() || qsizetype(header.profileSize) < qsizetype(sizeof(ICCProfileHeader))) {
qCWarning(lcIcc) << "fromIccProfile: failed size sanity 2";
return false;
}