From f28cd98661dc93174375d3c646aae18d13ddd920 Mon Sep 17 00:00:00 2001 From: Mirco Miranda Date: Sun, 21 Sep 2025 11:28:45 +0200 Subject: [PATCH] Limits the max DDS size to 300000x300000 pixels --- README.md | 2 +- src/imageformats/dds.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 74b0701..fd667c6 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ Below are the maximum sizes for each plugin ('n/a' means no limit, i.e. the limit depends on the format encoding). - ANI: n/a - AVIF: 32,768 x 32,768 pixels, in any case no larger than 256 megapixels -- DDS: n/a +- DDS: 300,000 x 300,000 pixels - EXR: 300,000 x 300,000 pixels - EPS: same size as Qt's JPG plugin - HDR: 300,000 x 300,000 pixels diff --git a/src/imageformats/dds.cpp b/src/imageformats/dds.cpp index f1efb12..7bccbb3 100644 --- a/src/imageformats/dds.cpp +++ b/src/imageformats/dds.cpp @@ -24,6 +24,16 @@ // #define DDS_DISABLE_STRIDE_ALIGNMENT #endif +/* *** DDS_MAX_IMAGE_WIDTH and DDS_MAX_IMAGE_HEIGHT *** + * The maximum size in pixel allowed by the plugin. + */ +#ifndef DDS_MAX_IMAGE_WIDTH +#define DDS_MAX_IMAGE_WIDTH KIF_LARGE_IMAGE_PIXEL_LIMIT +#endif +#ifndef DDS_MAX_IMAGE_HEIGHT +#define DDS_MAX_IMAGE_HEIGHT DDS_MAX_IMAGE_WIDTH +#endif + #ifdef QT_DEBUG Q_LOGGING_CATEGORY(LOG_DDSPLUGIN, "kf.imageformats.plugins.dds", QtDebugMsg) #else @@ -2543,8 +2553,8 @@ bool QDDSHandler::verifyHeader(const DDSHeader &dds) const return false; } - if (dds.width > INT_MAX || dds.height > INT_MAX) { - qCWarning(LOG_DDSPLUGIN) << "Can't read image with w/h bigger than INT_MAX"; + if (dds.width > DDS_MAX_IMAGE_WIDTH || dds.height > DDS_MAX_IMAGE_HEIGHT) { + qCWarning(LOG_DDSPLUGIN) << "Can't read image with size bigger than" << DDS_MAX_IMAGE_WIDTH << "x" << DDS_MAX_IMAGE_HEIGHT << "pixels"; return false; }