diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-02 22:38:57 -0700 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-19 07:27:02 +0000 |
commit | 8a5267e4d96438aa74672ca1bf25d187c6c45bd2 (patch) | |
tree | abb5b76025fac8489a68fae3d61708ba3c3ef930 /src/corelib/plugin/qfactoryloader_p.h | |
parent | 3c2ffd7457688bd8ae9d5fca688843e2029504b2 (diff) |
Plugins: fix crash if the binary JSON data contains invalid size
Eight bytes into the Binary JSON header there's a 32-bit little-endian
size, which qJsonFromRawLibraryMetaData uses to determine the size of
the stored metadata. That value is passed as a size to QByteArray, which
means certain values could cause crashes due to being too big or via
sign-extension in 64-bit.
[ChangeLog][QtCore][QPluginLoader] Fixed an issue that could cause a
crash when certain damaged or corrupt plugin files were scanned.
Change-Id: I117816bf0f5e469b8d34fffd153dc5425cec39a7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/plugin/qfactoryloader_p.h')
-rw-r--r-- | src/corelib/plugin/qfactoryloader_p.h | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 7be18942ae..fe722999ae 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -66,14 +66,7 @@ QT_BEGIN_NAMESPACE -inline QJsonDocument qJsonFromRawLibraryMetaData(const char *raw) -{ - raw += strlen("QTMETADATA "); - // the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h), - // but doesn't include the size of the header (8 bytes) - QByteArray json(raw, qFromLittleEndian<uint>(*(const uint *)(raw + 8)) + 8); - return QJsonDocument::fromBinaryData(json); -} +QJsonDocument qJsonFromRawLibraryMetaData(const char *raw, qsizetype size); class QFactoryLoaderPrivate; class Q_CORE_EXPORT QFactoryLoader : public QObject |