Raw ↗
+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
1 /*
2 * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0
3 * Copyright (c) 2026 Saif Mukhtar
4 *
5 * OpenAVX - Open Audio-Video eXchange
6 * fuzz/fuzz_rtsp_packetizer.c - libFuzzer Target for RTP Packetizer & Base64 Encoder
7 */
8  
9 #include <stdint.h>
10 #include <stddef.h>
11 #include <stdbool.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include "avx_rtsp.h"
15  
16 static void dummy_rtp_cb(const uint8_t *rtp_pkt, size_t rtp_len, void *user_data) {
17 (void)rtp_pkt;
18 (void)rtp_len;
19 (void)user_data;
20 }
21  
22 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
23 if (!data || size < 4) return 0;
24  
25 /* 1. Fuzz Base64 Encoder */
26 size_t b64_cap = ((size + 2) / 3) * 4 + 16;
27 char *b64_buf = (char*)malloc(b64_cap);
28 if (b64_buf) {
29 avx_base64_encode(data, size, b64_buf, b64_cap);
30 free(b64_buf);
31 }
32  
33 /* 2. Fuzz RTP Packetizer */
34 int codec_sel = data[0] % 3;
35 avx_rtsp_codec_e codec = (codec_sel == 0) ? AVX_RTSP_CODEC_H264 :
36 (codec_sel == 1) ? AVX_RTSP_CODEC_HEVC : AVX_RTSP_CODEC_AV1;
37  
38 uint16_t seq = (uint16_t)(data[1] | (data[2] << 8));
39 uint32_t ts = (uint32_t)(data[3] * 90000);
40 uint32_t ssrc = 0x12345678;
41 bool is_last = (data[0] & 0x08) != 0;
42  
43 avx_rtsp_rtp_packetize_nalu(
44 codec,
45 data + 4, size - 4,
46 ts, &seq, ssrc,
47 is_last,
48 dummy_rtp_cb,
49 NULL
50 );
51  
52 return 0;
53 }