summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2022-06-03 16:40:30 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-09 16:16:58 +0000
commit1121f7965a05d12262c61355ddfb348522270b44 (patch)
tree829d6caf03e466936561bd5c5c9d07475107b484
parentfedf3d9892f1530f51e4e5b9949fc8304fbdfb45 (diff)
Check earlier to avoid sanitzer warnings
Fixes oss-fuzz issue 47689: "load of value 65, which is not a valid value for type 'ICNSEntry::Depth'" Change-Id: Ia1b119d863e9518e308117ed1dd6a297297bc537 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit ea4684c6b17110d4ce0504f382da16462c048662) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/imageformats/icns/qicnshandler.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/imageformats/icns/qicnshandler.cpp b/src/plugins/imageformats/icns/qicnshandler.cpp
index 5089c42..f1cf240 100644
--- a/src/plugins/imageformats/icns/qicnshandler.cpp
+++ b/src/plugins/imageformats/icns/qicnshandler.cpp
@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
if (isIconCompressed(icon))
return true;
// Icon depth:
- if (!depth.isEmpty())
- icon.depth = ICNSEntry::Depth(depth.toUInt());
+ if (!depth.isEmpty()) {
+ const uint depthUInt = depth.toUInt();
+ if (depthUInt > 32)
+ return false;
+ icon.depth = ICNSEntry::Depth(depthUInt);
+ }
// Try mono if depth not found
if (icon.depth == ICNSEntry::DepthUnknown)
icon.depth = ICNSEntry::DepthMono;
@@ -516,7 +520,7 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
icon.height = icon.width;
}
// Sanity check
- if (icon.width == 0 || icon.width > 4096 || icon.depth > 32)
+ if (icon.width == 0 || icon.width > 4096)
return false;
return true;
}