File 0001-xcf-Fix-Stack-buffer-overflow-WRITE-on-broken-files.patch of Package kimageformats
From bc26c1936feaf1bc1d17d4325dfc9db33baf9aae Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Fri, 30 Apr 2021 00:07:21 +0200
Subject: [PATCH] xcf: Fix Stack-buffer-overflow WRITE on broken files
oss-fuzz/33742
(cherry picked from commit 297ed9a2fe339bfe36916b9fce628c3242e5be0f)
---
src/imageformats/xcf.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/imageformats/xcf.cpp b/src/imageformats/xcf.cpp
index 5bf6077..2154a1f 100644
--- a/src/imageformats/xcf.cpp
+++ b/src/imageformats/xcf.cpp
@@ -561,6 +561,7 @@ inline QRgb qRgba(const QRgb rgb, int a)
*/
XCFImageFormat::XCFImageFormat()
{
+ static_assert(sizeof(QRgb) == 4, "the code assumes sizeof(QRgb) == 4, if that's not your case, help us fix it :)");
}
/*!
@@ -1392,6 +1393,11 @@ bool XCFImageFormat::loadHierarchy(QDataStream &xcf_io, Layer &layer)
break;
}
+ if (bpp > 4) {
+ qCDebug(XCFPLUGIN) << "bpp is" << bpp << "We don't support layers with bpp > 4";
+ return false;
+ }
+
// GIMP stores images in a "mipmap"-like format (multiple levels of
// increasingly lower resolution). Only the top level is used here,
// however.
--
2.25.1