summaryrefslogtreecommitdiff
path: root/libavformat/flvdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-01-23 21:20:57 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-01-26 18:37:12 +0100
commit074e204b42acdacc0a055671481e00914524af93 (patch)
treec728531ab10345e13f4dc93c3b5d5fe2fb66fefd /libavformat/flvdec.c
parent59a6becf8ecb1ea25faaeaaf45f4d28de39606eb (diff)
avformat/flvdec: Check for nesting depth in amf_parse_object()
Fixes: out of array access Fixes: 29202/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5112845840809984 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r--libavformat/flvdec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 07ef342278..5e4af8eca4 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -41,6 +41,8 @@
#define RESYNC_BUFFER_SIZE (1<<20)
+#define MAX_DEPTH 16 ///< arbitrary limit to prevent unbounded recursion
+
typedef struct FLVContext {
const AVClass *class; ///< Class for private options.
int trust_metadata; ///< configure streams according onMetaData
@@ -493,6 +495,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
double num_val;
amf_date date;
+ if (depth > MAX_DEPTH)
+ return AVERROR_PATCHWELCOME;
+
num_val = 0;
ioc = s->pb;
if (avio_feof(ioc))