| 1 | Descriptionscip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/patches/`CVE-2020-23884.patch`#Description.: reject broken MNG images |
| 2 | Originscip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/patches/`CVE-2020-23884.patch`#Origin.: upstream, https://codereview.qt-project.org/c/qt/qtbase/+/303313 |
| 3 | For backport to Qt 5.15, add these checks directly to qtimageformats, not qtbase. |
| 4 | Last-Updatescip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/patches/`CVE-2020-23884.patch`#Last-Update.: 2024-10-28 |
| 5 | |
| 6 | --- a/src/plugins/imageformats/mng/mng.proscip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/upstream/`src/plugins/imageformats/mng/mng.pro`: |
| 7 | +++ b/src/plugins/imageformats/mng/mng.proscip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/upstream/`src/plugins/imageformats/mng/mng.pro`: |
| 8 | @@ -1,5 +1,6 @@ |
| 9 | TARGET = qmng |
| 10 | |
| 11 | +QT += gui-private |
| 12 | HEADERS += qmnghandler_p.h |
| 13 | SOURCES += main.cpp \ |
| 14 | qmnghandler.cpp |
| 15 | --- a/src/plugins/imageformats/mng/qmnghandler.cppscip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/upstream/`src/plugins/imageformats/mng/qmnghandler.cpp`: |
| 16 | +++ b/src/plugins/imageformats/mng/qmnghandler.cppscip-debian debian qtimageformats-opensource-src 5.15.19-2 qtimageformats-opensource-src/upstream/`src/plugins/imageformats/mng/qmnghandler.cpp`: |
| 17 | @@ -42,6 +42,7 @@ |
| 18 | #include "qimage.h" |
| 19 | #include "qvariant.h" |
| 20 | #include "qcolor.h" |
| 21 | +#include <private/qimage_p.h> |
| 22 | |
| 23 | #define MNG_USE_SO |
| 24 | #include <libmng.h> |
| 25 | @@ -247,6 +248,16 @@ mng_bool QMngHandlerPrivate::processHead |
| 26 | { |
| 27 | if (mng_set_canvasstyle(hMNG, iStyle) != MNG_NOERROR) |
| 28 | return MNG_FALSE; |
| 29 | + QImageData::ImageSizeParameters szp = |
| 30 | + QImageData::calculateImageParameters(iWidth, iHeight, 32); |
| 31 | + if (!szp.isValid()) |
| 32 | + return MNG_FALSE; |
| 33 | + // 256 MB is enough for an 8K 64bpp image |
| 34 | + if (szp.totalSize > 256 << 20) { |
| 35 | + qWarning("QMngHandler: Rejecting image as it exceeds the current " |
| 36 | + "allocation limit of 256 megabytes"); |
| 37 | + return MNG_FALSE; |
| 38 | + } |
| 39 | image = QImage(iWidth, iHeight, QImage::Format_ARGB32); |
| 40 | image.fill(0); |
| 41 | return MNG_TRUE; |