Coverage Report

Created: 2026-05-16 07:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/fuzzers/fuzzer_options_parser.c
Line
Count
Source
1
/*
2
 * This file is part of mpv.
3
 *
4
 * mpv is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * mpv is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with mpv.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
#include <stdint.h>
19
#include <stdlib.h>
20
#include <ctype.h>
21
22
#include "common.h"
23
24
int mpv_initialize_opts(mpv_handle *ctx, char **options);
25
26
17.8k
#define MAX_INPUT_SIZE 2048
27
254k
#define MAX_OPTS_NUM 10000
28
29
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
30
17.8k
{
31
17.8k
    char buff[MAX_INPUT_SIZE + 2];
32
33
17.8k
    if (!size || size > MAX_INPUT_SIZE)
34
12
        return 0;
35
36
17.8k
    memcpy(buff, data, size);
37
17.8k
    buff[size] = '\0';
38
17.8k
    buff[size + 1] = '\0';
39
40
17.8k
    char *opts[MAX_OPTS_NUM + 1];
41
17.8k
    char *opt = buff;
42
17.8k
    int count = 0;
43
272k
    while (*opt && count < MAX_OPTS_NUM) {
44
254k
        opts[count] = opt;
45
46
3.57M
        while (*opt && !isspace(*opt))
47
3.31M
            opt++;
48
49
254k
        *opt = '\0';
50
254k
        opt++;
51
52
262k
        while (*opt && isspace(*opt))
53
7.49k
            opt++;
54
55
254k
        count++;
56
254k
    }
57
17.8k
    opts[count] = NULL;
58
59
17.8k
    set_fontconfig_sysroot();
60
61
17.8k
    mpv_handle *ctx = mpv_create();
62
17.8k
    if (!ctx)
63
0
        exit(1);
64
65
17.8k
    mpv_initialize_opts(ctx, opts);
66
67
17.8k
    mpv_terminate_destroy(ctx);
68
69
17.8k
    return 0;
70
17.8k
}