Coverage Report

Created: 2026-05-31 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpegthumbs/build/autotests/ossfuzz/ffmpegthumbs_fuzzer.cc
Line
Count
Source
1
/*
2
 * SPDX-FileCopyrightText: 2025 Azhar Momin <azhar.momin@kdemail.net>
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 "ffmpegthumbnailer.h"
15
16
static void runThumbnailer(const QString &fileName, const QString &mimetype)
17
830
{
18
830
    QSize targetSize(128, 128);
19
830
    qreal dpr = 1.0;
20
830
    float sequenceIndex = 0.0f;
21
22
830
    KIO::ThumbnailRequest request(QUrl::fromLocalFile(fileName), targetSize, mimetype, dpr, sequenceIndex);
23
24
830
    FFMpegThumbnailer thumbnailer(nullptr, {});
25
830
    thumbnailer.create(request);
26
830
}
27
28
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
29
144k
{
30
144k
    int argc = 0;
31
144k
    QGuiApplication app(argc, nullptr);
32
33
144k
    QByteArray b(reinterpret_cast<const char *>(data), static_cast<int>(size));
34
35
144k
    QTemporaryFile f;
36
144k
    if (!f.open()) {
37
0
        return 0;
38
0
    }
39
144k
    f.write(b);
40
144k
    f.close();
41
42
144k
    QMimeDatabase mimeDb;
43
144k
    QMimeType mimetype = mimeDb.mimeTypeForData(b);
44
45
144k
    runThumbnailer(f.fileName(), mimetype.name());
46
267k
    for (const QString &ancestor : mimetype.allAncestors()) {
47
267k
        if (ancestor != QLatin1String("application/octet-stream")) {
48
135k
            runThumbnailer(f.fileName(), ancestor);
49
135k
        }
50
267k
    }
51
52
144k
    return 0;
53
144k
}