/src/mpv/fuzzers/fuzzer_loadfile_direct.c
Line | Count | Source (jump to first uncovered line) |
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 | 62.1k | { |
27 | 62.1k | if (size <= 1 || data[size - 1] != '\0') |
28 | 37 | return 0; |
29 | | |
30 | | // Exclude data with null bytes inside |
31 | 62.1k | if (strlen(data) != size - 1) |
32 | 42 | return 0; |
33 | | |
34 | | #ifdef MPV_PROTO |
35 | 56.0k | if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1)) |
36 | 53 | return 0; |
37 | 56.0k | #endif |
38 | | |
39 | 62.0k | mpv_handle *ctx = mpv_create(); |
40 | 62.0k | if (!ctx) |
41 | 0 | exit(1); |
42 | | |
43 | 62.0k | check_error(mpv_set_option_string(ctx, "vo", "null")); |
44 | 62.0k | check_error(mpv_set_option_string(ctx, "ao", "null")); |
45 | 62.0k | check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes")); |
46 | 62.0k | check_error(mpv_set_option_string(ctx, "untimed", "yes")); |
47 | 62.0k | check_error(mpv_set_option_string(ctx, "video-osd", "no")); |
48 | 62.0k | check_error(mpv_set_option_string(ctx, "msg-level", "all=trace")); |
49 | 62.0k | check_error(mpv_set_option_string(ctx, "network-timeout", "1")); |
50 | | |
51 | 62.0k | check_error(mpv_initialize(ctx)); |
52 | | |
53 | 62.0k | const char *cmd[] = {"loadfile", data, NULL}; |
54 | 62.0k | check_error(mpv_command(ctx, cmd)); |
55 | | |
56 | 62.0k | player_loop(ctx); |
57 | | |
58 | 62.0k | mpv_terminate_destroy(ctx); |
59 | | |
60 | 62.0k | return 0; |
61 | 62.0k | } Line | Count | Source | 26 | 56.1k | { | 27 | 56.1k | if (size <= 1 || data[size - 1] != '\0') | 28 | 37 | return 0; | 29 | | | 30 | | // Exclude data with null bytes inside | 31 | 56.1k | if (strlen(data) != size - 1) | 32 | 41 | return 0; | 33 | | | 34 | 56.0k | #ifdef MPV_PROTO | 35 | 56.0k | if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1)) | 36 | 53 | return 0; | 37 | 56.0k | #endif | 38 | | | 39 | 56.0k | mpv_handle *ctx = mpv_create(); | 40 | 56.0k | if (!ctx) | 41 | 0 | exit(1); | 42 | | | 43 | 56.0k | check_error(mpv_set_option_string(ctx, "vo", "null")); | 44 | 56.0k | check_error(mpv_set_option_string(ctx, "ao", "null")); | 45 | 56.0k | check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes")); | 46 | 56.0k | check_error(mpv_set_option_string(ctx, "untimed", "yes")); | 47 | 56.0k | check_error(mpv_set_option_string(ctx, "video-osd", "no")); | 48 | 56.0k | check_error(mpv_set_option_string(ctx, "msg-level", "all=trace")); | 49 | 56.0k | check_error(mpv_set_option_string(ctx, "network-timeout", "1")); | 50 | | | 51 | 56.0k | check_error(mpv_initialize(ctx)); | 52 | | | 53 | 56.0k | const char *cmd[] = {"loadfile", data, NULL}; | 54 | 56.0k | check_error(mpv_command(ctx, cmd)); | 55 | | | 56 | 56.0k | player_loop(ctx); | 57 | | | 58 | 56.0k | mpv_terminate_destroy(ctx); | 59 | | | 60 | 56.0k | return 0; | 61 | 56.0k | } |
Line | Count | Source | 26 | 6.01k | { | 27 | 6.01k | if (size <= 1 || data[size - 1] != '\0') | 28 | 0 | return 0; | 29 | | | 30 | | // Exclude data with null bytes inside | 31 | 6.01k | if (strlen(data) != size - 1) | 32 | 1 | return 0; | 33 | | | 34 | | #ifdef MPV_PROTO | 35 | | if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1)) | 36 | | return 0; | 37 | | #endif | 38 | | | 39 | 6.01k | mpv_handle *ctx = mpv_create(); | 40 | 6.01k | if (!ctx) | 41 | 0 | exit(1); | 42 | | | 43 | 6.01k | check_error(mpv_set_option_string(ctx, "vo", "null")); | 44 | 6.01k | check_error(mpv_set_option_string(ctx, "ao", "null")); | 45 | 6.01k | check_error(mpv_set_option_string(ctx, "ao-null-untimed", "yes")); | 46 | 6.01k | check_error(mpv_set_option_string(ctx, "untimed", "yes")); | 47 | 6.01k | check_error(mpv_set_option_string(ctx, "video-osd", "no")); | 48 | 6.01k | check_error(mpv_set_option_string(ctx, "msg-level", "all=trace")); | 49 | 6.01k | check_error(mpv_set_option_string(ctx, "network-timeout", "1")); | 50 | | | 51 | 6.01k | check_error(mpv_initialize(ctx)); | 52 | | | 53 | 6.01k | const char *cmd[] = {"loadfile", data, NULL}; | 54 | 6.01k | check_error(mpv_command(ctx, cmd)); | 55 | | | 56 | 6.01k | player_loop(ctx); | 57 | | | 58 | 6.01k | mpv_terminate_destroy(ctx); | 59 | | | 60 | 6.01k | return 0; | 61 | 6.01k | } |
|