From 90f0d522bf2c4a2d17fe04ccf342601222b5d4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20L=C3=B6hning?= Date: Tue, 4 Jan 2022 21:49:05 +0100 Subject: 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 --- tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'tests/libfuzzer/gui') 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 #include #include -#include -#include #include // 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; } -- cgit v1.2.3