diff options
Diffstat (limited to 'tests/libfuzzer')
42 files changed, 529 insertions, 594 deletions
diff --git a/tests/libfuzzer/README b/tests/libfuzzer/README index d0ab4fdda8..33aa309670 100644 --- a/tests/libfuzzer/README +++ b/tests/libfuzzer/README @@ -19,7 +19,7 @@ To run a test with libFuzzer: 3. Configure Qt with -platform linux-clang -sanitize fuzzer-no-link or, if you are using clang 5 - -platform linux-clang -coverage trace-pc-guard + -platform linux-clang -- -DCMAKE_CXX_FLAGS=-fsanitize-coverage=trace-pc-guard to add the needed code coverage instrumentation. Since speed of execution is crucial for fuzz testing, it's recommendable to also use the switches -release -static @@ -41,7 +41,8 @@ To run a test with libFuzzer: For further info about libFuzzer, see https://llvm.org/docs/LibFuzzer.html -Some of these tests are continuously being run on oss-fuzz which is documented at +Some of these tests are continuously being run on oss-fuzz, a service by Google for fuzzing free +software. It is documented at: https://google.github.io/oss-fuzz/ You can find: @@ -52,3 +53,24 @@ You can find: Update the date in the URL to get more recent data. - The found issues which were already published at: https://bugs.chromium.org/p/oss-fuzz/issues/list?q=proj%3Dqt + +You can reproduce issues found by oss-fuzz using their Docker images, see +https://google.github.io/oss-fuzz/advanced-topics/reproducing/ +Alternatively, you can also reproduce it locally with a native build: + +1. Read the tested submodule, the test's project and the architecture from the report. + For all findings since November 2020, you get the former from the "Fuzz Target". For example, + "qtbase_gui_text_qtextdocument_sethtml" is fuzzing qtbase using the project in + qtbase/tests/libfuzzer/gui/text/qtextdocument/sethtml/ + The architecture you can find in "Job Type". If it contains "i386" it is a 32-bit x86 build, + otherwise it is an x86_64 build. Sometimes you can reproduce issues on both architectures. +2. Build Qt including the tested submodule and its dependencies on the respective architecture with + the used sanitizer (see above). + The sanitizer is also written in the report. It is usually needed to reproduce the issue. +3. Use this Qt build to build the test's project. For example: + <qt-build>/qtbase/bin/qt-cmake -S "<src>/qtbase/tests/libfuzzer/gui/text/qtextdocument/sethtml/" + cmake --build . +4. Download the "Reproducer Testcase" from the report. +5. Start the binary resulting from step 3 and pass the testcase. For example: + ./sethtml input.html + You should get the same symptoms as described in the report. diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/CMakeLists.txt b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/CMakeLists.txt new file mode 100644 index 0000000000..bb614575d6 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(next LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(next + main.cpp +) + +target_link_libraries(next PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(next PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(next PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp index 118f402a15..19001628b2 100644 --- a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp +++ b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QCborStreamReader> diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro deleted file mode 100644 index 6c988c2434..0000000000 --- a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT -= gui -CONFIG += console -CONFIG -= app_bundle -SOURCES += main.cpp -FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) -isEmpty(FUZZ_ENGINE) { - QMAKE_LFLAGS += -fsanitize=fuzzer -} else { - LIBS += $$FUZZ_ENGINE -} diff --git a/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/CMakeLists.txt b/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/CMakeLists.txt new file mode 100644 index 0000000000..1ced99cfc4 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(fromcbor LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(fromcbor + main.cpp +) + +target_link_libraries(fromcbor PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(fromcbor PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(fromcbor PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/fromcbor.pro b/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/fromcbor.pro deleted file mode 100644 index 6c988c2434..0000000000 --- a/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/fromcbor.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT -= gui -CONFIG += console -CONFIG -= app_bundle -SOURCES += main.cpp -FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) -isEmpty(FUZZ_ENGINE) { - QMAKE_LFLAGS += -fsanitize=fuzzer -} else { - LIBS += $$FUZZ_ENGINE -} diff --git a/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/main.cpp b/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/main.cpp index 5e2a440d1b..b82b0303ca 100644 --- a/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/main.cpp +++ b/tests/libfuzzer/corelib/serialization/qcborvalue/fromcbor/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QCborValue> diff --git a/tests/libfuzzer/corelib/serialization/qjsondocument/fromjson/CMakeLists.txt b/tests/libfuzzer/corelib/serialization/qjsondocument/fromjson/CMakeLists.txt new file mode 100644 index 0000000000..095c4733e4 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qjsondocument/fromjson/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(fromjson LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(fromjson + main.cpp +) + +target_link_libraries(fromjson PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(fromjson PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(fromjson PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/serialization/qjsondocument/fromjson/main.cpp b/tests/libfuzzer/corelib/serialization/qjsondocument/fromjson/main.cpp new file mode 100644 index 0000000000..dec863fd2b --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qjsondocument/fromjson/main.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QJsonDocument> + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QJsonDocument::fromJson(QByteArray::fromRawData(Data, Size)); + return 0; +} diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/CMakeLists.txt b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/CMakeLists.txt new file mode 100644 index 0000000000..4ab7142d8e --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(extractionoperator-float LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(extractionoperator-float + main.cpp +) + +target_link_libraries(extractionoperator-float PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(extractionoperator-float PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(extractionoperator-float PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro deleted file mode 100644 index 6c988c2434..0000000000 --- a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT -= gui -CONFIG += console -CONFIG -= app_bundle -SOURCES += main.cpp -FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) -isEmpty(FUZZ_ENGINE) { - QMAKE_LFLAGS += -fsanitize=fuzzer -} else { - LIBS += $$FUZZ_ENGINE -} diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp index 10d5c3222e..01a80ab293 100644 --- a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp +++ b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTextStream> diff --git a/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/CMakeLists.txt b/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/CMakeLists.txt new file mode 100644 index 0000000000..642b862da7 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(readnext LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(readnext + main.cpp +) + +target_link_libraries(readnext PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(readnext PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(readnext PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/main.cpp b/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/main.cpp index 7b73e6e952..b1f6dc5e50 100644 --- a/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/main.cpp +++ b/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QXmlStreamReader> diff --git a/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/readnext.pro b/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/readnext.pro deleted file mode 100644 index 6c988c2434..0000000000 --- a/tests/libfuzzer/corelib/serialization/qxmlstream/qxmlstreamreader/readnext/readnext.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT -= gui -CONFIG += console -CONFIG -= app_bundle -SOURCES += main.cpp -FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) -isEmpty(FUZZ_ENGINE) { - QMAKE_LFLAGS += -fsanitize=fuzzer -} else { - LIBS += $$FUZZ_ENGINE -} diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt b/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt index 303f2494db..fcacd7c67d 100644 --- a/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/CMakeLists.txt @@ -1,27 +1,30 @@ -# Generated from optimize.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -##################################################################### -## optimize Binary: -##################################################################### +cmake_minimum_required(VERSION 3.16) +project(optimize LANGUAGES CXX) -qt_internal_add_executable(optimize - GUI - SOURCES - main.cpp -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) -#### Keys ignored in scope 1:.:.:optimize.pro:<TRUE>: -# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -## Scopes: -##################################################################### +find_package(Qt6 REQUIRED COMPONENTS Core) -qt_internal_extend_target(optimize CONDITION FUZZ_ENGINE_ISEMPTY - LINK_OPTIONS - "-fsanitize=fuzzer" +qt_add_executable(optimize + main.cpp ) -qt_internal_extend_target(optimize CONDITION NOT FUZZ_ENGINE_ISEMPTY - PUBLIC_LIBRARIES - $ENV{LIB_FUZZING_ENGINE} +target_link_libraries(optimize PUBLIC + Qt::Core ) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(optimize PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(optimize PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp b/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp index 30a714c250..335b6c0552 100644 --- a/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QRegularExpression> diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro b/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro deleted file mode 100644 index 196aca42eb..0000000000 --- a/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro +++ /dev/null @@ -1,8 +0,0 @@ -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/corelib/time/qdatetime/fromstring/CMakeLists.txt b/tests/libfuzzer/corelib/time/qdatetime/fromstring/CMakeLists.txt new file mode 100644 index 0000000000..b4ffa66760 --- /dev/null +++ b/tests/libfuzzer/corelib/time/qdatetime/fromstring/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(fromstring LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(fromstring + main.cpp +) + +target_link_libraries(fromstring PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(fromstring PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(fromstring PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/time/qdatetime/fromstring/fromstring.pro b/tests/libfuzzer/corelib/time/qdatetime/fromstring/fromstring.pro deleted file mode 100644 index 631fcd71e4..0000000000 --- a/tests/libfuzzer/corelib/time/qdatetime/fromstring/fromstring.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT -= gui -CONFIG -= app_bundle -CONFIG += console -SOURCES += main.cpp -FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) -isEmpty(FUZZ_ENGINE) { - QMAKE_LFLAGS += -fsanitize=fuzzer -} else { - LIBS += $$FUZZ_ENGINE -} diff --git a/tests/libfuzzer/corelib/time/qdatetime/fromstring/main.cpp b/tests/libfuzzer/corelib/time/qdatetime/fromstring/main.cpp index e41301bb55..a0bbe9b03d 100644 --- a/tests/libfuzzer/corelib/time/qdatetime/fromstring/main.cpp +++ b/tests/libfuzzer/corelib/time/qdatetime/fromstring/main.cpp @@ -1,34 +1,16 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDateTime> +// Enable to report the currently used format, e.g. when reproducing issues +// #define LOG_FORMAT +#ifdef LOG_FORMAT +#include <QDebug> +#endif + static const QString formats[] = { + QStringLiteral("M/d/yyyy"), QStringLiteral("h"), QStringLiteral("hh"), QStringLiteral("H"), @@ -41,7 +23,6 @@ static const QString formats[] = { QStringLiteral("zzz"), QStringLiteral("A"), QStringLiteral("t"), - QStringLiteral("M/d/yyyy"), QStringLiteral("M/d/yyyy hh:mm"), QStringLiteral("M/d/yyyy hh:mm A"), QStringLiteral("M/d/yyyy, hh:mm"), @@ -93,7 +74,14 @@ extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) QDateTime::fromString(userString, Qt::RFC2822Date); QDateTime::fromString(userString, Qt::ISODateWithMs); + QDateTime::fromString(userString, formats[0], QCalendar(QCalendar::System::Gregorian)); + for (int sys = int(QCalendar::System::Julian); sys <= int(QCalendar::System::Last); ++sys) + QDateTime::fromString(userString, formats[0], QCalendar(QCalendar::System(sys))); + for (const auto &format : formats) { + #ifdef LOG_FORMAT + qDebug() << "Trying format:" << format; + #endif QDateTime::fromString(userString, format); } return 0; diff --git a/tests/libfuzzer/corelib/tools/qcryptographichash/result/CMakeLists.txt b/tests/libfuzzer/corelib/tools/qcryptographichash/result/CMakeLists.txt new file mode 100644 index 0000000000..ceb2f673e8 --- /dev/null +++ b/tests/libfuzzer/corelib/tools/qcryptographichash/result/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(result LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core) + +qt_add_executable(result + main.cpp +) + +target_link_libraries(result PUBLIC + Qt::Core +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(result PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(result PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/corelib/tools/qcryptographichash/result/main.cpp b/tests/libfuzzer/corelib/tools/qcryptographichash/result/main.cpp index 71780898bc..738da38e29 100644 --- a/tests/libfuzzer/corelib/tools/qcryptographichash/result/main.cpp +++ b/tests/libfuzzer/corelib/tools/qcryptographichash/result/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QCryptographicHash> diff --git a/tests/libfuzzer/corelib/tools/qcryptographichash/result/result.pro b/tests/libfuzzer/corelib/tools/qcryptographichash/result/result.pro deleted file mode 100644 index 6c988c2434..0000000000 --- a/tests/libfuzzer/corelib/tools/qcryptographichash/result/result.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT -= gui -CONFIG += console -CONFIG -= app_bundle -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/image/qimage/loadfromdata/CMakeLists.txt b/tests/libfuzzer/gui/image/qimage/loadfromdata/CMakeLists.txt new file mode 100644 index 0000000000..9c97294077 --- /dev/null +++ b/tests/libfuzzer/gui/image/qimage/loadfromdata/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(loadfromdata LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core Gui) + +qt_add_executable(loadfromdata + main.cpp +) + +target_link_libraries(loadfromdata PUBLIC + Qt::Core + Qt::Gui +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(loadfromdata PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(loadfromdata PRIVATE + -fsanitize=fuzzer + ) +endif() + +qt_import_plugins(loadfromdata + INCLUDE Qt::QMinimalIntegrationPlugin +) diff --git a/tests/libfuzzer/gui/image/qimage/loadfromdata/loadfromdata.pro b/tests/libfuzzer/gui/image/qimage/loadfromdata/loadfromdata.pro deleted file mode 100644 index 204bd6569d..0000000000 --- a/tests/libfuzzer/gui/image/qimage/loadfromdata/loadfromdata.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += gui -!isEmpty(QT.svg.name) { - QT += svg -} -QTPLUGIN *= qminimal -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/image/qimage/loadfromdata/main.cpp b/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp index 54d1ed0ee6..951b8f4637 100644 --- a/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp +++ b/tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp @@ -1,36 +1,8 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#include <QBuffer> #include <QGuiApplication> #include <QImage> -#include <QImageReader> -#include <QSize> #include <QtGlobal> // silence warnings @@ -44,12 +16,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; } diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt index 14daff2a7a..808d4e435c 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/CMakeLists.txt @@ -1,30 +1,35 @@ -# Generated from fromiccprofile.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -##################################################################### -## fromiccprofile Binary: -##################################################################### +cmake_minimum_required(VERSION 3.16) +project(fromiccprofile LANGUAGES CXX) -qt_internal_add_executable(fromiccprofile - GUI - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Gui -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) -#### Keys ignored in scope 1:.:.:fromiccprofile.pro:<TRUE>: -# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" -# QTPLUGIN = "qminimal" +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -## Scopes: -##################################################################### +find_package(Qt6 REQUIRED COMPONENTS Core Gui) -qt_internal_extend_target(fromiccprofile CONDITION FUZZ_ENGINE_ISEMPTY - LINK_OPTIONS - "-fsanitize=fuzzer" +qt_add_executable(fromiccprofile + main.cpp ) -qt_internal_extend_target(fromiccprofile CONDITION NOT FUZZ_ENGINE_ISEMPTY - PUBLIC_LIBRARIES +target_link_libraries(fromiccprofile PUBLIC + Qt::Core + Qt::Gui +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(fromiccprofile PRIVATE $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(fromiccprofile PRIVATE + -fsanitize=fuzzer + ) +endif() + +qt_import_plugins(fromiccprofile + INCLUDE Qt::QMinimalIntegrationPlugin ) diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro deleted file mode 100644 index bed2198e0d..0000000000 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += gui -QTPLUGIN *= qminimal -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/main.cpp b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp index 943f85d92e..3b9e843405 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp @@ -1,35 +1,27 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <cstdlib> #include <QGuiApplication> +#include <QColor> #include <QColorSpace> +#include <QImage> + +static QImage::Format toFormat(QColorSpace::ColorModel model) +{ + switch (model) { + case QColorSpace::ColorModel::Rgb: + return QImage::Format_RGB32; + case QColorSpace::ColorModel::Gray: + return QImage::Format_Grayscale16; + case QColorSpace::ColorModel::Cmyk: + return QImage::Format_CMYK8888; + case QColorSpace::ColorModel::Undefined: + break; + } + return QImage::Format_Invalid; +} extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) { // to reduce noise and increase speed @@ -43,5 +35,27 @@ extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) { static char *argv[] = {arg1, arg2, arg3, nullptr}; static QGuiApplication qga(argc, argv); QColorSpace cs = QColorSpace::fromIccProfile(QByteArray::fromRawData(data, size)); + if (cs.isValid()) { + cs.description(); + QColorTransform trans1 = cs.transformationToColorSpace(QColorSpace::SRgb); + trans1.isIdentity(); + QColorSpace cs2 = cs; + cs2.setDescription("Hello"); + bool b = (cs == cs2); + Q_UNUSED(b); + QColor color(0xfaf8fa00); + color = trans1.map(color); + QImage img(16, 2, toFormat(cs.colorModel())); + img.setColorSpace(cs); + QImage img2 = img.convertedToColorSpace(QColorSpace::SRgb); + if (cs.isValidTarget()) { + QImage img3 = img2.convertedToColorSpace(cs); + + QColorTransform trans2 = QColorSpace(QColorSpace::SRgb).transformationToColorSpace(cs); + bool a = (trans1 == trans2); + Q_UNUSED(a); + color = trans2.map(color); + } + } return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt b/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt index 1fefea0128..906ee30384 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/CMakeLists.txt @@ -1,30 +1,35 @@ -# Generated from sethtml.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -##################################################################### -## sethtml Binary: -##################################################################### +cmake_minimum_required(VERSION 3.16) +project(sethtml LANGUAGES CXX) -qt_internal_add_executable(sethtml - GUI - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Gui -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) -#### Keys ignored in scope 1:.:.:sethtml.pro:<TRUE>: -# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" -# QTPLUGIN = "qminimal" +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -## Scopes: -##################################################################### +find_package(Qt6 REQUIRED COMPONENTS Core Gui) -qt_internal_extend_target(sethtml CONDITION FUZZ_ENGINE_ISEMPTY - LINK_OPTIONS - "-fsanitize=fuzzer" +qt_add_executable(sethtml + main.cpp ) -qt_internal_extend_target(sethtml CONDITION NOT FUZZ_ENGINE_ISEMPTY - PUBLIC_LIBRARIES +target_link_libraries(sethtml PUBLIC + Qt::Core + Qt::Gui +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(sethtml PRIVATE $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(sethtml PRIVATE + -fsanitize=fuzzer + ) +endif() + +qt_import_plugins(sethtml + INCLUDE Qt::QMinimalIntegrationPlugin ) diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp b/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp index ed2a5c4e37..6cac5d20ec 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp @@ -1,33 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include <QTextDocument> +#include <QtGlobal> + +// silence warnings +static QtMessageHandler mh = qInstallMessageHandler([](QtMsgType, const QMessageLogContext &, + const QString &) {}); extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { static int argc = 3; diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro b/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro deleted file mode 100644 index bed2198e0d..0000000000 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += gui -QTPLUGIN *= qminimal -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/text/qtextdocument/setmarkdown/CMakeLists.txt b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/CMakeLists.txt index acc678f2ef..0fdf3dfaf8 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/CMakeLists.txt +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/CMakeLists.txt @@ -1,30 +1,35 @@ -# Generated from setmarkdown.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -##################################################################### -## setmarkdown Binary: -##################################################################### +cmake_minimum_required(VERSION 3.16) +project(setmarkdown LANGUAGES CXX) -qt_internal_add_executable(setmarkdown - GUI - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Gui -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) -#### Keys ignored in scope 1:.:.:setmarkdown.pro:<TRUE>: -# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" -# QTPLUGIN = "qminimal" +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -## Scopes: -##################################################################### +find_package(Qt6 REQUIRED COMPONENTS Core Gui) -qt_internal_extend_target(setmarkdown CONDITION FUZZ_ENGINE_ISEMPTY - LINK_OPTIONS - "-fsanitize=fuzzer" +qt_add_executable(setmarkdown + main.cpp ) -qt_internal_extend_target(setmarkdown CONDITION NOT FUZZ_ENGINE_ISEMPTY - PUBLIC_LIBRARIES +target_link_libraries(setmarkdown PUBLIC + Qt::Core + Qt::Gui +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(setmarkdown PRIVATE $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(setmarkdown PRIVATE + -fsanitize=fuzzer + ) +endif() + +qt_import_plugins(setmarkdown + INCLUDE Qt::QMinimalIntegrationPlugin ) diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp index 6093da9827..d9678d5453 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp @@ -1,33 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include <QTextDocument> +#include <QtGlobal> + +// silence warnings +static QtMessageHandler mh = qInstallMessageHandler([](QtMsgType, const QMessageLogContext &, + const QString &) {}); extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { static int argc = 3; diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro deleted file mode 100644 index bed2198e0d..0000000000 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += gui -QTPLUGIN *= qminimal -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/text/qtextlayout/beginlayout/CMakeLists.txt b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/CMakeLists.txt index 637ce2f51b..468b37a8f9 100644 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/CMakeLists.txt +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/CMakeLists.txt @@ -1,30 +1,35 @@ -# Generated from beginlayout.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -##################################################################### -## beginlayout Binary: -##################################################################### +cmake_minimum_required(VERSION 3.16) +project(beginlayout LANGUAGES CXX) -qt_internal_add_executable(beginlayout - GUI - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Gui -) +set(CMAKE_INCLUDE_CURRENT_DIR ON) -#### Keys ignored in scope 1:.:.:beginlayout.pro:<TRUE>: -# FUZZ_ENGINE = "$$(LIB_FUZZING_ENGINE)" -# QTPLUGIN = "qminimal" +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -## Scopes: -##################################################################### +find_package(Qt6 REQUIRED COMPONENTS Core Gui) -qt_internal_extend_target(beginlayout CONDITION FUZZ_ENGINE_ISEMPTY - LINK_OPTIONS - "-fsanitize=fuzzer" +qt_add_executable(beginlayout + main.cpp ) -qt_internal_extend_target(beginlayout CONDITION NOT FUZZ_ENGINE_ISEMPTY - PUBLIC_LIBRARIES +target_link_libraries(beginlayout PUBLIC + Qt::Core + Qt::Gui +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(beginlayout PRIVATE $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(beginlayout PRIVATE + -fsanitize=fuzzer + ) +endif() + +qt_import_plugins(beginlayout + INCLUDE Qt::QMinimalIntegrationPlugin ) diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro deleted file mode 100644 index bed2198e0d..0000000000 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += gui -QTPLUGIN *= qminimal -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/text/qtextlayout/beginlayout/main.cpp b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp index 27e0566c2c..ae6d84bd5c 100644 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include <QTextLayout> diff --git a/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/CMakeLists.txt b/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/CMakeLists.txt new file mode 100644 index 0000000000..d7c4f0a2f7 --- /dev/null +++ b/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(pem LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core Network) + +qt_add_executable(pem + main.cpp +) + +target_link_libraries(pem PUBLIC + Qt::Core + Qt::Network +) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + target_link_libraries(pem PRIVATE + $ENV{LIB_FUZZING_ENGINE} + ) +else() + target_link_libraries(pem PRIVATE + -fsanitize=fuzzer + ) +endif() diff --git a/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/main.cpp b/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/main.cpp index fd491e2b93..4baf3df357 100644 --- a/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/main.cpp +++ b/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/main.cpp @@ -1,34 +1,13 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QSslCertificate> extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + // to reduce noise and increase speed + static char quiet[] = "QT_LOGGING_RULES=qt.*=false"; + static int pe = putenv(quiet); + Q_UNUSED(pe); QSslCertificate ssl(QByteArray::fromRawData(Data, Size), QSsl::Pem); return 0; } diff --git a/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/pem.pro b/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/pem.pro deleted file mode 100644 index 7f3781eaba..0000000000 --- a/tests/libfuzzer/network/ssl/qsslcertificate/qsslcertificate/pem/pem.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT -= gui -QT += network -CONFIG += console -CONFIG -= app_bundle -SOURCES += main.cpp -FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) -isEmpty(FUZZ_ENGINE) { - QMAKE_LFLAGS += -fsanitize=fuzzer -} else { - LIBS += $$FUZZ_ENGINE -} |