1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "config.h"
22
28
30
31 static void error(
const char *err)
32 {
33 fprintf(stderr, "%s", err);
34 exit(1);
35 }
36
38
39 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
40
43 const uint8_t *last =
data;
47 uint64_t keyframes = 0;
48 uint64_t flushpattern = -1;
49 int res;
50
52 #ifdef FFMPEG_BSF
53 #define BSF_SYMBOL0(BSF) ff_##BSF##_bsf
54 #define BSF_SYMBOL(BSF) BSF_SYMBOL0(BSF)
56 f = &BSF_SYMBOL(FFMPEG_BSF);
57 #endif
59 }
60
62 if (res < 0)
63 error(
"Failed memory allocation");
65
68 int extradata_size;
76
83 }
84
85 extradata_size = bytestream2_get_le32(&gbc);
86
90 keyframes = bytestream2_get_le64(&gbc);
91 flushpattern = bytestream2_get_le64(&gbc);
92 flags = bytestream2_get_byte(&gbc);
93
95 if (!strcmp(
f->
name,
"av1_metadata"))
97 else if (!strcmp(
f->
name,
"h264_metadata") || !strcmp(
f->
name,
"h265_metadata"))
99 else if (!strcmp(
f->
name,
"extract_extradata"))
101 }
102
103 if (extradata_size <
size) {
109 }
110 }
113 }
114
116 if (res < 0) {
118 return 0; // Failure of av_bsf_init() does not imply that a issue was found
119 }
120
123 error(
"Failed memory allocation");
124
126 // Search for the TAG
127 while (
data +
sizeof(fuzz_tag) < end) {
129 break;
131 }
132 if (
data +
sizeof(fuzz_tag) > end)
134
136 if (res < 0)
137 error(
"Failed memory allocation");
140 keyframes = (keyframes >> 2) + (keyframes<<62);
141 data +=
sizeof(fuzz_tag);
143
144 if (!(flushpattern & 7))
146 flushpattern = (flushpattern >> 3) + (flushpattern << 61);
147
149 if (res < 0) {
151 continue;
152 }
155 }
156
160
163 return 0;
164 }