diff options
Diffstat (limited to 'tests/libfuzzer')
15 files changed, 230 insertions, 13 deletions
diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt b/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt new file mode 100644 index 0000000000..a82e5fa340 --- /dev/null +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt @@ -0,0 +1,27 @@ +# Generated from optimize.pro. + +##################################################################### +## optimize Binary: +##################################################################### + +qt_add_executable(optimize + GUI + SOURCES + main.cpp +) + +#### Keys ignored in scope 1:.:.:optimize.pro:<TRUE>: +# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" + +## Scopes: +##################################################################### + +qt_extend_target(optimize CONDITION FUZZ_ENGINE_ISEMPTY + LINK_OPTIONS + "-fsanitize=fuzzer" +) + +qt_extend_target(optimize CONDITION NOT FUZZ_ENGINE_ISEMPTY + PUBLIC_LIBRARIES + $ENV{LIB_FUZZING_ENGINE} +) diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp b/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp new file mode 100644 index 0000000000..30a714c250 --- /dev/null +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QRegularExpression> + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QRegularExpression qre(QByteArray::fromRawData(Data, Size)); + qre.optimize(); + return 0; +} diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro b/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro new file mode 100644 index 0000000000..196aca42eb --- /dev/null +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro @@ -0,0 +1,8 @@ +QT -= gui +SOURCES += main.cpp +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt new file mode 100644 index 0000000000..ec52626e2d --- /dev/null +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from fromiccprofile.pro. + +##################################################################### +## fromiccprofile Binary: +##################################################################### + +qt_add_executable(fromiccprofile + GUI + SOURCES + main.cpp + PUBLIC_LIBRARIES + Qt::Gui +) + +#### Keys ignored in scope 1:.:.:fromiccprofile.pro:<TRUE>: +# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" +# QTPLUGIN = "qminimal" + +## Scopes: +##################################################################### + +qt_extend_target(fromiccprofile CONDITION FUZZ_ENGINE_ISEMPTY + LINK_OPTIONS + "-fsanitize=fuzzer" +) + +qt_extend_target(fromiccprofile CONDITION NOT FUZZ_ENGINE_ISEMPTY + PUBLIC_LIBRARIES + $ENV{LIB_FUZZING_ENGINE} +) diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro index 934ff81077..bed2198e0d 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro @@ -1,4 +1,5 @@ QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp index 7681c1468e..8a588c6e21 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp @@ -26,16 +26,22 @@ ** ****************************************************************************/ +#include <cstdlib> + #include <QGuiApplication> #include <QColorSpace> -// Run this with -// QT_LOGGING_RULES="qt.gui.icc=false" -// to reduce noise and increase speed. - extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) { - static int c = 0; - static QGuiApplication a(c, nullptr); + // to reduce noise and increase speed + static char quiet[] = "QT_LOGGING_RULES=qt.gui.icc=false"; + static int pe = putenv(quiet); + Q_UNUSED(pe) + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QColorSpace cs = QColorSpace::fromIccProfile(QByteArray::fromRawData(data, size)); return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt b/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt new file mode 100644 index 0000000000..982957bedf --- /dev/null +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from sethtml.pro. + +##################################################################### +## sethtml Binary: +##################################################################### + +qt_add_executable(sethtml + GUI + SOURCES + main.cpp + PUBLIC_LIBRARIES + Qt::Gui +) + +#### Keys ignored in scope 1:.:.:sethtml.pro:<TRUE>: +# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" +# QTPLUGIN = "qminimal" + +## Scopes: +##################################################################### + +qt_extend_target(sethtml CONDITION FUZZ_ENGINE_ISEMPTY + LINK_OPTIONS + "-fsanitize=fuzzer" +) + +qt_extend_target(sethtml CONDITION NOT FUZZ_ENGINE_ISEMPTY + PUBLIC_LIBRARIES + $ENV{LIB_FUZZING_ENGINE} +) diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp b/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp index 51fa3c9e0f..ed2a5c4e37 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp @@ -26,12 +26,16 @@ ** ****************************************************************************/ -#include <QApplication> +#include <QGuiApplication> #include <QTextDocument> extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { - static int c = 0; - static QApplication a(c, nullptr); + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QTextDocument().setHtml(QByteArray::fromRawData(Data, Size)); return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro b/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro index af5ef9e940..bed2198e0d 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro @@ -1,4 +1,5 @@ -QT += widgets +QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/CMakeLists.txt b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/CMakeLists.txt new file mode 100644 index 0000000000..a10d432556 --- /dev/null +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from setmarkdown.pro. + +##################################################################### +## setmarkdown Binary: +##################################################################### + +qt_add_executable(setmarkdown + GUI + SOURCES + main.cpp + PUBLIC_LIBRARIES + Qt::Gui +) + +#### Keys ignored in scope 1:.:.:setmarkdown.pro:<TRUE>: +# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" +# QTPLUGIN = "qminimal" + +## Scopes: +##################################################################### + +qt_extend_target(setmarkdown CONDITION FUZZ_ENGINE_ISEMPTY + LINK_OPTIONS + "-fsanitize=fuzzer" +) + +qt_extend_target(setmarkdown CONDITION NOT FUZZ_ENGINE_ISEMPTY + PUBLIC_LIBRARIES + $ENV{LIB_FUZZING_ENGINE} +) diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp index 66ddf738f2..6093da9827 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp @@ -26,9 +26,16 @@ ** ****************************************************************************/ +#include <QGuiApplication> #include <QTextDocument> extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QTextDocument().setMarkdown(QByteArray::fromRawData(Data, Size)); return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro index 758622e1af..bed2198e0d 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro @@ -1,5 +1,5 @@ -CONFIG += console -CONFIG -= app_bundle +QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/CMakeLists.txt b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/CMakeLists.txt new file mode 100644 index 0000000000..1810c5ed6f --- /dev/null +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from beginlayout.pro. + +##################################################################### +## beginlayout Binary: +##################################################################### + +qt_add_executable(beginlayout + GUI + SOURCES + main.cpp + PUBLIC_LIBRARIES + Qt::Gui +) + +#### Keys ignored in scope 1:.:.:beginlayout.pro:<TRUE>: +# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" +# QTPLUGIN = "qminimal" + +## Scopes: +##################################################################### + +qt_extend_target(beginlayout CONDITION FUZZ_ENGINE_ISEMPTY + LINK_OPTIONS + "-fsanitize=fuzzer" +) + +qt_extend_target(beginlayout CONDITION NOT FUZZ_ENGINE_ISEMPTY + PUBLIC_LIBRARIES + $ENV{LIB_FUZZING_ENGINE} +) diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro index af5ef9e940..bed2198e0d 100644 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro @@ -1,4 +1,5 @@ -QT += widgets +QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp index dfb9559241..27e0566c2c 100644 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp @@ -26,9 +26,16 @@ ** ****************************************************************************/ +#include <QGuiApplication> #include <QTextLayout> extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QTextLayout tl(QByteArray::fromRawData(Data, Size)); tl.beginLayout(); tl.endLayout(); |