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"
23
29
31
32 static void error(
const char *err)
33 {
34 fprintf(stderr, "%s", err);
35 exit(1);
36 }
37
39
40 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
41
44 const uint8_t *last =
data;
48 uint64_t keyframes = 0;
49 uint64_t flushpattern = -1;
50 int res;
51
53 #ifdef FFMPEG_BSF
54 #define BSF_SYMBOL0(BSF) ff_##BSF##_bsf
55 #define BSF_SYMBOL(BSF) BSF_SYMBOL0(BSF)
57 f = &BSF_SYMBOL(FFMPEG_BSF);
58 #endif
60 }
61
63 if (res < 0)
64 error(
"Failed memory allocation");
66
69 int extradata_size;
77
84 }
85
86 extradata_size = bytestream2_get_le32(&gbc);
87
91 keyframes = bytestream2_get_le64(&gbc);
92 flushpattern = bytestream2_get_le64(&gbc);
93 flags = bytestream2_get_byte(&gbc);
94
96 if (!strcmp(
f->
name,
"av1_metadata"))
98 else if (!strcmp(
f->
name,
"h264_metadata") || !strcmp(
f->
name,
"hevc_metadata") ||
99 !strcmp(
f->
name,
"vvc_metadata"))
101 else if (!strcmp(
f->
name,
"extract_extradata"))
103 }
104
105 if (extradata_size <
size) {
111 }
112 }
115 }
116
118 if (res < 0) {
120 return 0; // Failure of av_bsf_init() does not imply that a issue was found
121 }
122
125 error(
"Failed memory allocation");
126
128 // Search for the TAG
129 while (
data +
sizeof(fuzz_tag) < end) {
131 break;
133 }
134 if (
data +
sizeof(fuzz_tag) > end)
136
138 if (res < 0)
139 error(
"Failed memory allocation");
142 keyframes = (keyframes >> 2) + (keyframes<<62);
143 data +=
sizeof(fuzz_tag);
145
146 if (!(flushpattern & 7))
148 flushpattern = (flushpattern >> 3) + (flushpattern << 61);
149
151 if (res < 0) {
153 continue;
154 }
157 }
158
162
165 return 0;
166 }