Coverage Report

Created: 2025-10-10 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rtpproxy/scripts/fuzz/fuzz_standalone.h
Line
Count
Source
1
#pragma once
2
3
#if defined(FUZZ_STANDALONE)
4
#include <assert.h>
5
#include <fcntl.h>
6
#include <stdlib.h>
7
#include <string.h>
8
#include <unistd.h>
9
#endif /* FUZZ_STANDALONE */
10
11
#if defined(FUZZ_STANDALONE)
12
extern int LLVMFuzzerInitialize(int *argc, char ***argv) __attribute__((__weak__));
13
14
int LLVMFuzzerTestOneInput(const char *data, size_t size);
15
16
__attribute__((constructor)) static void
17
rtpp_init()
18
{
19
    if (LLVMFuzzerInitialize != NULL) {
20
        int r = LLVMFuzzerInitialize(NULL, NULL);
21
        if (r != 0)
22
            abort();
23
    }
24
}
25
26
int
27
main(int argc, char *argv[])
28
{
29
    int fflag, ch, fd;
30
    char buf[1024], *cp;
31
    size_t size;
32
33
    fflag = 0;
34
    while ((ch = getopt(argc, argv, "f")) != -1) {
35
        switch (ch) {
36
        case 'f':
37
            fflag = 1;
38
            break;
39
        default:
40
            return (-1);
41
        }
42
    }
43
    argc -= optind;
44
    argv += optind;
45
46
    assert(argc == 1);
47
    if (fflag) {
48
        fd = open(argv[0], O_RDONLY, 0);
49
        assert(fd >= 0);
50
        size = read(fd, buf, sizeof(buf));
51
        assert(size > 0);
52
        cp = buf;
53
    } else {
54
        cp = argv[0];
55
        size = strlen(cp);
56
    }
57
    LLVMFuzzerTestOneInput(cp, size);
58
    return (0);
59
}
60
#else
61
0
const char *__asan_default_options() {
62
0
  return "verbosity=0";
63
0
}
64
#endif /* FUZZ_STANDALONE */