From 1f27c1161b3cf71485d24124497afb12907792ce Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 2 Jul 2018 21:28:56 -0700 Subject: QPluginLoader: limit the amount of memory used when scanning plugins When using actual memory allocation, limit to 64 MB, not the full file size. On most systems, the memory map technique will work, so this won't even be tried. In any case, we don't need the fix for the OOM situation that was applied in commit e211ab76d766878b4dbe88901b9a7a4a70ce7332. As for the memory mapping technique, this commit limits the allocation to reasonable values given the virtual memory addressing space. Half a gigabyte is probably acceptable on 32-bit systems, where there should be a contiguous space for the OS to allocate the file in. This commit also fixes an overflow when converting from qint64 of the file size to ulong (32-bit on 32-bit platforms and on Windows). For 64-bit systems, we currently limit to 1 TB. Change-Id: I117816bf0f5e469b8d34fffd153dc1705a8eedc4 Reviewed-by: Simon Hausmann --- tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 499d276ef8..a496ed318b 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -345,8 +345,8 @@ void tst_QPluginLoader::loadMachO() QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray data = f.readAll(); - long pos; - ulong len; + qsizetype pos; + qsizetype len; QString errorString; int r = QMachOParser::parse(data.constData(), data.size(), f.fileName(), &errorString, &pos, &len); -- cgit v1.2.3