Coverage Report

Created: 2025-11-14 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/test/vlc-demux-libfuzzer.c
Line
Count
Source
1
/**
2
 * @file vlc-demux-test.c
3
 */
4
/*****************************************************************************
5
 * Copyright © 2016 Rémi Denis-Courmont
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * Rémi Denis-Courmont reserves the right to redistribute this file under
13
 * the terms of the GNU Lesser General Public License as published by the
14
 * the Free Software Foundation; either version 2.1 or the License, or
15
 * (at his option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software Foundation,
24
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25
 *****************************************************************************/
26
27
#ifdef HAVE_CONFIG_H
28
# include "config.h"
29
#endif
30
31
#include <stdint.h>
32
#include <stdlib.h>
33
#include <string.h>
34
#include "src/input/demux-run.h"
35
36
int LLVMFuzzerInitialize(int *argc, char ***argv);
37
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
38
39
static struct vlc_run_args args;
40
static libvlc_instance_t *vlc;
41
42
int LLVMFuzzerInitialize(int *argc, char ***argv)
43
54
{
44
54
    (void) argc;
45
54
    vlc_run_args_init(&args);
46
47
54
    if (args.name == NULL)
48
54
    {
49
54
        char *name = *argv[0];
50
54
        static const char suffix[] = "-libfuzzer";
51
54
        static const size_t suffix_len = sizeof(suffix) - 1;
52
54
        char *target_start = strstr(name, suffix);
53
54
        if (target_start != NULL && target_start[suffix_len] == '-')
54
52
            args.name = &target_start[suffix_len + 1];
55
54
    }
56
54
    vlc = libvlc_create(&args);
57
58
54
    return vlc ? 0 : -1;
59
54
}
60
61
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
62
89.2k
{
63
89.2k
    libvlc_demux_process_memory(vlc, &args, data, size);
64
89.2k
    return 0;
65
89.2k
}