/src/rtpproxy/scripts/fuzz/fuzz_rtcp_parser.c
Line | Count | Source |
1 | | #include <assert.h> |
2 | | #include <stdio.h> |
3 | | #include <stdlib.h> |
4 | | #include <stdint.h> |
5 | | #include <unistd.h> |
6 | | |
7 | | #include "rtpp_types.h" |
8 | | #include "rtp_packet.h" |
9 | | #include "rtpp_module.h" |
10 | | #include "rtpp_module_if_static.h" |
11 | | #include "rtpp_sbuf.h" |
12 | | #include "rtcp2json.h" |
13 | | |
14 | | #include "fuzz_standalone.h" |
15 | | |
16 | | static const struct rtpp_minfo_fset minfo_fset = { |
17 | | ._malloc = &malloc, |
18 | | ._realloc = &realloc, |
19 | | ._free = &free |
20 | | }; |
21 | | |
22 | | __attribute__((constructor)) void |
23 | | fuzz_rtcp_parser_init() |
24 | 2 | { |
25 | 2 | const struct rtpp_minfo *mip; |
26 | | |
27 | 2 | mip = rtpp_static_modules_lookup("acct_rtcp_hep"); |
28 | 2 | assert(mip != NULL); |
29 | 2 | *mip->fn = minfo_fset; |
30 | 2 | } |
31 | | |
32 | | int |
33 | | LLVMFuzzerTestOneInput(const char *rtcp_data, size_t rtcp_dlen) |
34 | 370 | { |
35 | 370 | struct rtpp_sbuf *sbp; |
36 | | |
37 | 370 | if (rtcp_dlen > MAX_RPKT_LEN) |
38 | 0 | return (0); |
39 | | |
40 | 370 | sbp = rtpp_sbuf_ctor(512); |
41 | 370 | assert (sbp != NULL); |
42 | | #if 0 |
43 | | for (size_t i = 0; i < rtcp_dlen; i++) { |
44 | | char bf[3]; |
45 | | sprintf(bf, "%.2x", rtcp_data[i]); |
46 | | write(STDERR_FILENO, bf, 2); |
47 | | } |
48 | | write(STDERR_FILENO, "\n", 1); |
49 | | fsync(STDERR_FILENO); |
50 | | #endif |
51 | 370 | rtcp2json(sbp, rtcp_data, rtcp_dlen); |
52 | 370 | rtpp_sbuf_dtor(sbp); |
53 | | |
54 | 370 | return (0); |
55 | 370 | } |