Fuzzing: Add QGuiApplication to gui fuzz targets

Change-Id: I3713701f63d9d8938fbb42ad1ae2f0c4ae813e94
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Robert Loehning 2020-03-20 11:54:14 +01:00
parent 68916fede4
commit cd57dae62f
8 changed files with 34 additions and 9 deletions

View File

@ -1,4 +1,5 @@
QT += gui
QTPLUGIN *= qminimal
SOURCES += main.cpp
FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE)
isEmpty(FUZZ_ENGINE) {

View File

@ -34,8 +34,12 @@
// 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);
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;
}

View File

@ -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;
}

View File

@ -1,4 +1,5 @@
QT += widgets
QT += gui
QTPLUGIN *= qminimal
SOURCES += main.cpp
FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE)
isEmpty(FUZZ_ENGINE) {

View File

@ -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;
}

View File

@ -1,5 +1,5 @@
CONFIG += console
CONFIG -= app_bundle
QT += gui
QTPLUGIN *= qminimal
SOURCES += main.cpp
FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE)
isEmpty(FUZZ_ENGINE) {

View File

@ -1,4 +1,5 @@
QT += widgets
QT += gui
QTPLUGIN *= qminimal
SOURCES += main.cpp
FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE)
isEmpty(FUZZ_ENGINE) {

View File

@ -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();