mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-02 15:26:00 +08:00
qt 6.5.1 original
This commit is contained in:
76
tests/libfuzzer/README
Normal file
76
tests/libfuzzer/README
Normal file
@ -0,0 +1,76 @@
|
||||
This directory contains tests to be run with clang's libFuzzer. It will generate data, pass this
|
||||
data to the function
|
||||
|
||||
LLVMFuzzerTestOneInput(const char *Data, size_t Size)
|
||||
|
||||
of the test and track the code execution. Should the test crash, libFuzzer will provide you with the
|
||||
data which triggered the crash. You can then use this to debug and fix the called code.
|
||||
|
||||
! Please note: The purpose of fuzz testing is to find unexpected code paths. Running fuzz tests may!
|
||||
! result in unforeseen behavior, including loss of data. Consider running the tests in an isolated !
|
||||
! environment, e.g. on a virtual machine. You have been warned. !
|
||||
|
||||
To run a test with libFuzzer:
|
||||
|
||||
1. Install clang 5.0 or later, e.g. from the repositories of the Linux distribution you are using.
|
||||
Depending on the version of clang and the source you are installing from, you might have to
|
||||
install libFuzzer for this version of clang explicitly.
|
||||
2. Make sure clang and clang++ from this version of clang are found in PATH.
|
||||
3. Configure Qt with
|
||||
-platform linux-clang -sanitize fuzzer-no-link
|
||||
or, if you are using clang 5
|
||||
-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
|
||||
It might also make sense to add sanitizers by passing
|
||||
-sanitize <...>
|
||||
4. Build Qt.
|
||||
5. Build one of the tests using this Qt build.
|
||||
6. Execute the resulting executable.
|
||||
Depending on the expected input format of the tested function, you will get results faster if
|
||||
you:
|
||||
* provide a set of interesting input data by passing the path of a directory which contains
|
||||
these data, each in one file. You can find such data sets in the subdirectory
|
||||
"fuzzing/testcases" of the qtqa repository.
|
||||
* pass a so-called dictionary listing keywords of the input format using
|
||||
-dict=<dictionary file>
|
||||
A couple of such dictionaries are provided by AFL (http://lcamtuf.coredump.cx/afl/)
|
||||
* tell libFuzzer to generate only ASCII data using
|
||||
-only_ascii=1
|
||||
|
||||
For further info about libFuzzer, see https://llvm.org/docs/LibFuzzer.html
|
||||
|
||||
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:
|
||||
- The build logs for Qt at
|
||||
https://oss-fuzz-build-logs.storage.googleapis.com/index.html#qt
|
||||
- The code coverage of the running fuzzers at
|
||||
https://storage.googleapis.com/oss-fuzz-coverage/qt/reports/20201104/linux/report.html
|
||||
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.
|
@ -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()
|
@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QCborStreamReader>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
QCborStreamReader reader(QByteArray::fromRawData(Data, Size));
|
||||
while (reader.isValid())
|
||||
reader.next(1024);
|
||||
return 0;
|
||||
}
|
@ -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()
|
@ -0,0 +1,9 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QCborValue>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
QCborValue::fromCbor(QByteArray::fromRawData(Data, Size));
|
||||
return 0;
|
||||
}
|
@ -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()
|
@ -0,0 +1,9 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
QJsonDocument::fromJson(QByteArray::fromRawData(Data, Size));
|
||||
return 0;
|
||||
}
|
@ -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()
|
@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
QTextStream qts(QByteArray::fromRawData(Data, Size));
|
||||
float f;
|
||||
qts >> f;
|
||||
return 0;
|
||||
}
|
@ -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()
|
@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2018 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
QXmlStreamReader reader(QByteArray::fromRawData(Data, Size));
|
||||
while (!reader.atEnd())
|
||||
reader.readNext();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(optimize 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(optimize
|
||||
main.cpp
|
||||
)
|
||||
|
||||
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()
|
@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
QRegularExpression qre(QByteArray::fromRawData(Data, Size));
|
||||
qre.optimize();
|
||||
return 0;
|
||||
}
|
@ -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()
|
88
tests/libfuzzer/corelib/time/qdatetime/fromstring/main.cpp
Normal file
88
tests/libfuzzer/corelib/time/qdatetime/fromstring/main.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#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"),
|
||||
QStringLiteral("HH"),
|
||||
QStringLiteral("m"),
|
||||
QStringLiteral("mm"),
|
||||
QStringLiteral("s"),
|
||||
QStringLiteral("ss"),
|
||||
QStringLiteral("z"),
|
||||
QStringLiteral("zzz"),
|
||||
QStringLiteral("A"),
|
||||
QStringLiteral("t"),
|
||||
QStringLiteral("M/d/yyyy hh:mm"),
|
||||
QStringLiteral("M/d/yyyy hh:mm A"),
|
||||
QStringLiteral("M/d/yyyy, hh:mm"),
|
||||
QStringLiteral("M/d/yyyy, hh:mm A"),
|
||||
QStringLiteral("MMM d yyyy"),
|
||||
QStringLiteral("MMM d yyyy hh:mm"),
|
||||
QStringLiteral("MMM d yyyy hh:mm:ss"),
|
||||
QStringLiteral("MMM d yyyy, hh:mm"),
|
||||
QStringLiteral("MMM d yyyy, hh:mm:ss"),
|
||||
QStringLiteral("MMMM d yyyy"),
|
||||
QStringLiteral("MMMM d yyyy hh:mm"),
|
||||
QStringLiteral("MMMM d yyyy hh:mm:ss"),
|
||||
QStringLiteral("MMMM d yyyy, hh:mm"),
|
||||
QStringLiteral("MMMM d yyyy, hh:mm:ss"),
|
||||
QStringLiteral("MMMM d yyyy, hh:mm:ss t"),
|
||||
QStringLiteral("MMM d, yyyy"),
|
||||
QStringLiteral("MMM d, yyyy hh:mm"),
|
||||
QStringLiteral("MMM d, yyyy hh:mm:ss"),
|
||||
QStringLiteral("MMMM d, yyyy"),
|
||||
QStringLiteral("MMMM d, yyyy hh:mm"),
|
||||
QStringLiteral("MMMM d, yyyy hh:mm:ss"),
|
||||
QStringLiteral("MMMM d, yyyy hh:mm:ss t"),
|
||||
QStringLiteral("d MMM yyyy"),
|
||||
QStringLiteral("d MMM yyyy hh:mm"),
|
||||
QStringLiteral("d MMM yyyy hh:mm:ss"),
|
||||
QStringLiteral("d MMM yyyy, hh:mm"),
|
||||
QStringLiteral("d MMM yyyy, hh:mm:ss"),
|
||||
QStringLiteral("d MMMM yyyy"),
|
||||
QStringLiteral("d MMMM yyyy hh:mm"),
|
||||
QStringLiteral("d MMMM yyyy hh:mm:ss"),
|
||||
QStringLiteral("d MMMM yyyy, hh:mm"),
|
||||
QStringLiteral("d MMMM yyyy, hh:mm:ss"),
|
||||
QStringLiteral("d MMM, yyyy"),
|
||||
QStringLiteral("d MMM, yyyy hh:mm"),
|
||||
QStringLiteral("d MMM, yyyy hh:mm:ss"),
|
||||
QStringLiteral("d MMMM, yyyy"),
|
||||
QStringLiteral("d MMMM, yyyy hh:mm"),
|
||||
QStringLiteral("d MMMM, yyyy hh:mm:ss"),
|
||||
QStringLiteral("yyyy-MM-ddThh:mm:ss.zt"),
|
||||
};
|
||||
|
||||
// libFuzzer entry-point for testing QDateTimeParser
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size)
|
||||
{
|
||||
const QString userString = QString::fromUtf8(Data, Size);
|
||||
|
||||
QDateTime::fromString(userString, Qt::TextDate);
|
||||
QDateTime::fromString(userString, Qt::ISODate);
|
||||
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;
|
||||
}
|
@ -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()
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
|
||||
for (QCryptographicHash::Algorithm algo = QCryptographicHash::Md4;
|
||||
algo <= QCryptographicHash::RealSha3_512;
|
||||
algo = QCryptographicHash::Algorithm(algo + 1)) {
|
||||
QCryptographicHash qh(algo);
|
||||
qh.addData(QByteArray::fromRawData(Data, Size));
|
||||
qh.result();
|
||||
}
|
||||
return 0;
|
||||
}
|
35
tests/libfuzzer/gui/image/qimage/loadfromdata/CMakeLists.txt
Normal file
35
tests/libfuzzer/gui/image/qimage/loadfromdata/CMakeLists.txt
Normal file
@ -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
|
||||
)
|
21
tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp
Normal file
21
tests/libfuzzer/gui/image/qimage/loadfromdata/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QImage>
|
||||
#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;
|
||||
static char arg1[] = "fuzzer";
|
||||
static char arg2[] = "-platform";
|
||||
static char arg3[] = "minimal";
|
||||
static char *argv[] = {arg1, arg2, arg3, nullptr};
|
||||
static QGuiApplication qga(argc, argv);
|
||||
QImage().loadFromData(QByteArray::fromRawData(Data, Size));
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(fromiccprofile 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(fromiccprofile
|
||||
main.cpp
|
||||
)
|
||||
|
||||
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
|
||||
)
|
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QColorSpace>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) {
|
||||
// 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;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(sethtml 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(sethtml
|
||||
main.cpp
|
||||
)
|
||||
|
||||
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
|
||||
)
|
21
tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp
Normal file
21
tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#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;
|
||||
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;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(setmarkdown 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(setmarkdown
|
||||
main.cpp
|
||||
)
|
||||
|
||||
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
|
||||
)
|
21
tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp
Normal file
21
tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#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;
|
||||
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;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(beginlayout 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(beginlayout
|
||||
main.cpp
|
||||
)
|
||||
|
||||
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
|
||||
)
|
18
tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp
Normal file
18
tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#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();
|
||||
return 0;
|
||||
}
|
@ -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()
|
@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user