Limits the max DDS size to 300000x300000 pixels

This commit is contained in:
Mirco Miranda
2025-09-21 11:28:45 +02:00
parent 05c3a1afe6
commit f28cd98661
2 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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;
}