summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobert Löhning <robert.loehning@qt.io>2022-01-04 21:49:05 +0100
committerRobert Löhning <robert.loehning@qt.io>2022-01-12 22:10:01 +0000
commit90f0d522bf2c4a2d17fe04ccf342601222b5d4a5 (patch)
tree07b39b07a54cce98b6d3d1e23132a231f57591fb /tests
parent2baa7eb260085555433d2e22c0b7606b9ee1a02e (diff)
Fuzzing: Don't explicitly restrict sizes before loading images
Since Qt 6.0, QImageIOHandlers by default take care of this themselves by not allocating more than 128 MiB for an image. This change will not significantly reduce code coverage of the fuzzer because QImage::loadFromData() calls QImageReader::read() which does everything QImageReader::size() does except for returning the read size in the end. On the other hand, it will speed up the execution because the same image will not be read twice by different QImageReaders anymore. Change-Id: Iab63d9e5ec02fbe5765fbf7ccb0b82896ec37692 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp13
1 files changed, 2 insertions, 11 deletions
diff --git a/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp b/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp
index 54d1ed0ee6..4a34d8fe5d 100644
--- a/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp
+++ b/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -26,11 +26,8 @@
**
****************************************************************************/
-#include <QBuffer>
#include <QGuiApplication>
#include <QImage>
-#include <QImageReader>
-#include <QSize>
#include <QtGlobal>
// silence warnings
@@ -44,12 +41,6 @@ extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
static char arg3[] = "minimal";
static char *argv[] = {arg1, arg2, arg3, nullptr};
static QGuiApplication qga(argc, argv);
- QByteArray input(QByteArray::fromRawData(Data, Size));
- QBuffer buf(&input);
- const QSize size = QImageReader(&buf).size();
- // Don't try to load huge valid images.
- // They are justified in using huge memory.
- if (!size.isValid() || uint64_t(size.width()) * size.height() < 64 * 1024 * 1024)
- QImage().loadFromData(input);
+ QImage().loadFromData(QByteArray::fromRawData(Data, Size));
return 0;
}