diff options
author | Robert Loehning <robert.loehning@qt.io> | 2022-06-03 16:40:30 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-09 15:16:57 +0000 |
commit | afd4c61898abf89737dd3c2d8b1329067bde3f4b (patch) | |
tree | 6509a7a8979e4b2e6d340213449f6d75c38c6164 | |
parent | 6d4058c6dcbb8814cd7d6ab896a46bd237a5f95f (diff) | |
download | qtimageformats-afd4c61898abf89737dd3c2d8b1329067bde3f4b.tar.gz |
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.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/imageformats/icns/qicnshandler.cpp b/src/plugins/imageformats/icns/qicnshandler.cpp index f924219..b665c83 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; } |