JXR: set max XMP size to 4MiB

This commit is contained in:
Mirco Miranda 2025-01-15 16:39:26 +01:00 committed by Daniel Novomeský
parent 65a587afad
commit a89367dde6

View File

@ -73,6 +73,13 @@ Q_LOGGING_CATEGORY(LOG_JXRPLUGIN, "kf.imageformats.plugins.jxr", QtWarningMsg)
// #define JXR_ENABLE_ADVANCED_METADATA // #define JXR_ENABLE_ADVANCED_METADATA
#ifndef JXR_MAX_METADATA_SIZE
/*!
* XMP and EXIF maximum size.
*/
#define JXR_MAX_METADATA_SIZE (4 * 1024 * 1024)
#endif
class JXRHandlerPrivate : public QSharedData class JXRHandlerPrivate : public QSharedData
{ {
private: private:
@ -300,7 +307,7 @@ public:
} }
#ifdef JXR_ENABLE_ADVANCED_METADATA #ifdef JXR_ENABLE_ADVANCED_METADATA
quint32 size; quint32 size;
if (!PKImageDecode_GetXMPMetadata_WMP(pDecoder, nullptr, &size) && size) { if (!PKImageDecode_GetXMPMetadata_WMP(pDecoder, nullptr, &size) && size > 0 && size < JXR_MAX_METADATA_SIZE) {
QByteArray ba(size, 0); QByteArray ba(size, 0);
if (!PKImageDecode_GetXMPMetadata_WMP(pDecoder, reinterpret_cast<quint8 *>(ba.data()), &size)) { if (!PKImageDecode_GetXMPMetadata_WMP(pDecoder, reinterpret_cast<quint8 *>(ba.data()), &size)) {
xmp = QString::fromUtf8(ba); xmp = QString::fromUtf8(ba);