| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2025 Azhar Momin <[email protected]> |
| 3 |
* SPDX-License-Identifier: LGPL-2.0-or-later |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <QByteArray> |
| 7 |
#include <QGuiApplication> |
| 8 |
#include <QMimeDatabase> |
| 9 |
#include <QSize> |
| 10 |
#include <QTemporaryFile> |
| 11 |
#include <QUrl> |
| 12 |
#include <QVariant> |
| 13 |
|
| 14 |
#include "@CREATOR_HEADER@" |
| 15 |
|
| 16 |
static void runThumbnailer(const QString &fileName, const QString &mimetype) |
| 17 |
{ |
| 18 |
QSize targetSize(128, 128); |
| 19 |
qreal dpr = 1.0; |
| 20 |
float sequenceIndex = 0.0f; |
| 21 |
|
| 22 |
KIO::ThumbnailRequest request(QUrl::fromLocalFile(fileName), targetSize, mimetype, dpr, sequenceIndex); |
| 23 |
|
| 24 |
@CREATOR@ thumbnailer(nullptr, {}); |
| 25 |
thumbnailer.create(request); |
| 26 |
} |
| 27 |
|
| 28 |
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
| 29 |
{ |
| 30 |
int argc = 0; |
| 31 |
QGuiApplication app(argc, nullptr); |
| 32 |
|
| 33 |
QByteArray b(reinterpret_cast<const char *>(data), static_cast<int>(size)); |
| 34 |
|
| 35 |
QTemporaryFile f; |
| 36 |
if (!f.open()) { |
| 37 |
return 0; |
| 38 |
} |
| 39 |
f.write(b); |
| 40 |
f.close(); |
| 41 |
|
| 42 |
QMimeDatabase mimeDb; |
| 43 |
QMimeType mimetype = mimeDb.mimeTypeForData(b); |
| 44 |
|
| 45 |
runThumbnailer(f.fileName(), mimetype.name()); |
| 46 |
for (const QString &ancestor : mimetype.allAncestors()) { |
| 47 |
if (ancestor != QLatin1String("application/octet-stream")) { |
| 48 |
runThumbnailer(f.fileName(), ancestor); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |