/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 "rtp_packet.h" |
8 | | #include "rtpp_module.h" |
9 | | #include "rtpp_module_if_static.h" |
10 | | #include "rtpp_sbuf.h" |
11 | | #include "rtcp2json.h" |
12 | | |
13 | | #include "fuzz_standalone.h" |
14 | | |
15 | | __attribute__((constructor)) void |
16 | | fuzz_rtcp_parser_init() |
17 | 2 | { |
18 | 2 | struct rtpp_minfo *mip; |
19 | | |
20 | 2 | mip = rtpp_static_modules_lookup("acct_rtcp_hep"); |
21 | 2 | assert(mip != NULL); |
22 | 2 | mip->_malloc = &malloc; |
23 | 2 | mip->_realloc = &realloc; |
24 | 2 | mip->_free = &free; |
25 | 2 | } |
26 | | |
27 | | int |
28 | | LLVMFuzzerTestOneInput(const char *rtcp_data, size_t rtcp_dlen) |
29 | 386 | { |
30 | 386 | struct rtpp_sbuf *sbp; |
31 | | |
32 | 386 | if (rtcp_dlen > MAX_RPKT_LEN) |
33 | 9 | return (0); |
34 | | |
35 | 377 | sbp = rtpp_sbuf_ctor(512); |
36 | 377 | assert (sbp != NULL); |
37 | | #if 0 |
38 | | for (size_t i = 0; i < rtcp_dlen; i++) { |
39 | | char bf[3]; |
40 | | sprintf(bf, "%.2x", rtcp_data[i]); |
41 | | write(STDERR_FILENO, bf, 2); |
42 | | } |
43 | | write(STDERR_FILENO, "\n", 1); |
44 | | fsync(STDERR_FILENO); |
45 | | #endif |
46 | 377 | rtcp2json(sbp, rtcp_data, rtcp_dlen); |
47 | 377 | rtpp_sbuf_dtor(sbp); |
48 | | |
49 | 377 | return (0); |
50 | 377 | } |