Coverage Report

Created: 2025-12-27 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/fuzzers/fuzzer_loadfile_direct.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 <stdlib.h>
19
#include <string.h>
20
21
#include <unistd.h>
22
23
#include "common.h"
24
25
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
26
64.6k
{
27
64.6k
    if (size > MAX_FUZZ_SIZE)
28
13
        return 0;
29
30
64.6k
    if (size <= 1 || data[size - 1] != '\0')
31
35
        return 0;
32
33
    // Exclude data with null bytes inside
34
64.6k
    if (strlen(data) != size - 1)
35
32
        return 0;
36
37
#ifdef MPV_PROTO
38
63.7k
    if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
39
54
        return 0;
40
63.7k
#endif
41
42
64.5k
    set_fontconfig_sysroot();
43
44
64.5k
    mpv_handle *ctx = mpv_create();
45
64.5k
    if (!ctx)
46
0
        exit(1);
47
48
64.5k
    check_error(mpv_set_option_string(ctx, "vo", "null"));
49
64.5k
    check_error(mpv_set_option_string(ctx, "ao", "null"));
50
64.5k
    check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes"));
51
64.5k
    check_error(mpv_set_option_string(ctx, "untimed", "yes"));
52
64.5k
    check_error(mpv_set_option_string(ctx, "video-osd", "no"));
53
64.5k
    check_error(mpv_set_option_string(ctx, "msg-level", "all=trace"));
54
64.5k
    check_error(mpv_set_option_string(ctx, "network-timeout", "1"));
55
56
64.5k
    check_error(mpv_initialize(ctx));
57
58
64.5k
    const char *cmd[] = {"loadfile", data, NULL};
59
64.5k
    check_error(mpv_command(ctx, cmd));
60
61
64.5k
    player_loop(ctx);
62
63
64.5k
    mpv_terminate_destroy(ctx);
64
65
64.5k
    return 0;
66
64.5k
}
LLVMFuzzerTestOneInput
Line
Count
Source
26
63.8k
{
27
63.8k
    if (size > MAX_FUZZ_SIZE)
28
10
        return 0;
29
30
63.8k
    if (size <= 1 || data[size - 1] != '\0')
31
35
        return 0;
32
33
    // Exclude data with null bytes inside
34
63.7k
    if (strlen(data) != size - 1)
35
31
        return 0;
36
37
63.7k
#ifdef MPV_PROTO
38
63.7k
    if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
39
54
        return 0;
40
63.7k
#endif
41
42
63.7k
    set_fontconfig_sysroot();
43
44
63.7k
    mpv_handle *ctx = mpv_create();
45
63.7k
    if (!ctx)
46
0
        exit(1);
47
48
63.7k
    check_error(mpv_set_option_string(ctx, "vo", "null"));
49
63.7k
    check_error(mpv_set_option_string(ctx, "ao", "null"));
50
63.7k
    check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes"));
51
63.7k
    check_error(mpv_set_option_string(ctx, "untimed", "yes"));
52
63.7k
    check_error(mpv_set_option_string(ctx, "video-osd", "no"));
53
63.7k
    check_error(mpv_set_option_string(ctx, "msg-level", "all=trace"));
54
63.7k
    check_error(mpv_set_option_string(ctx, "network-timeout", "1"));
55
56
63.7k
    check_error(mpv_initialize(ctx));
57
58
63.7k
    const char *cmd[] = {"loadfile", data, NULL};
59
63.7k
    check_error(mpv_command(ctx, cmd));
60
61
63.7k
    player_loop(ctx);
62
63
63.7k
    mpv_terminate_destroy(ctx);
64
65
63.7k
    return 0;
66
63.7k
}
LLVMFuzzerTestOneInput
Line
Count
Source
26
808
{
27
808
    if (size > MAX_FUZZ_SIZE)
28
3
        return 0;
29
30
805
    if (size <= 1 || data[size - 1] != '\0')
31
0
        return 0;
32
33
    // Exclude data with null bytes inside
34
805
    if (strlen(data) != size - 1)
35
1
        return 0;
36
37
#ifdef MPV_PROTO
38
    if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
39
        return 0;
40
#endif
41
42
804
    set_fontconfig_sysroot();
43
44
804
    mpv_handle *ctx = mpv_create();
45
804
    if (!ctx)
46
0
        exit(1);
47
48
804
    check_error(mpv_set_option_string(ctx, "vo", "null"));
49
804
    check_error(mpv_set_option_string(ctx, "ao", "null"));
50
804
    check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes"));
51
804
    check_error(mpv_set_option_string(ctx, "untimed", "yes"));
52
804
    check_error(mpv_set_option_string(ctx, "video-osd", "no"));
53
804
    check_error(mpv_set_option_string(ctx, "msg-level", "all=trace"));
54
804
    check_error(mpv_set_option_string(ctx, "network-timeout", "1"));
55
56
804
    check_error(mpv_initialize(ctx));
57
58
804
    const char *cmd[] = {"loadfile", data, NULL};
59
804
    check_error(mpv_command(ctx, cmd));
60
61
804
    player_loop(ctx);
62
63
804
    mpv_terminate_destroy(ctx);
64
65
804
    return 0;
66
804
}