MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

tools/target_dem_fuzzer.c:101–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99const int maxblocks= 50000;
100
101int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
102 uint32_t it = 0;
103 AVFormatContext *avfmt = avformat_alloc_context();
104 AVPacket *pkt;
105 char filename[1025] = {0};
106 AVIOContext *fuzzed_pb = NULL;
107 uint8_t *io_buffer;
108 int io_buffer_size = 32768;
109 int64_t filesize = size;
110 IOContext opaque;
111 static int c;
112 int seekable = 0;
113 int ret;
114 const AVInputFormat *fmt = NULL;
115#ifdef FFMPEG_DEMUXER
116#define DEMUXER_SYMBOL0(DEMUXER) ff_##DEMUXER##_demuxer
117#define DEMUXER_SYMBOL(DEMUXER) DEMUXER_SYMBOL0(DEMUXER)
118 extern const FFInputFormat DEMUXER_SYMBOL(FFMPEG_DEMUXER);
119 fmt = &DEMUXER_SYMBOL(FFMPEG_DEMUXER).p;
120#endif
121
122 if (!c) {
123 av_log_set_level(AV_LOG_PANIC);
124 c=1;
125 }
126
127 if (!avfmt)
128 error("Failed avformat_alloc_context()");
129
130 if (IO_FLAT) {
131 seekable = 1;
132 io_buffer_size = size;
133 } else if (size > 2048) {
134 int flags;
135 char extension[64];
136
137 GetByteContext gbc;
138 memcpy (filename, data + size - 1024, 1024);
139 bytestream2_init(&gbc, data + size - 2048, 1024);
140 size -= 2048;
141
142 io_buffer_size = bytestream2_get_le32(&gbc) & 0xFFFFFFF;
143 flags = bytestream2_get_byte(&gbc);
144 seekable = flags & 1;
145 filesize = bytestream2_get_le64(&gbc) & 0x7FFFFFFFFFFFFFFF;
146
147 if ((flags & 2) && strlen(filename) < sizeof(filename) / 2) {
148 const AVInputFormat *avif = NULL;
149 void *avif_iter = NULL;
150 int avif_count = 0;
151 while ((avif = av_demuxer_iterate(&avif_iter))) {
152 if (avif->extensions)
153 avif_count ++;
154 }
155 avif_count = bytestream2_get_le32(&gbc) % avif_count;
156
157 avif_iter = NULL;
158 while ((avif = av_demuxer_iterate(&avif_iter))) {

Callers

nothing calls this directly

Calls 15

avformat_alloc_contextFunction · 0.85
av_log_set_levelFunction · 0.85
bytestream2_initFunction · 0.85
av_demuxer_iterateFunction · 0.85
av_strlcpyFunction · 0.85
av_strlcatfFunction · 0.85
av_packet_allocFunction · 0.85
avformat_free_contextFunction · 0.85
av_packet_freeFunction · 0.85
avio_alloc_contextFunction · 0.85
avformat_open_inputFunction · 0.85

Tested by

no test coverage detected