aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-01-23 21:20:57 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-11 21:23:48 +0200
commitd99234eec2ed3c6445f4673533c3fec9f9f81a07 (patch)
tree66bc9e4e71bf153b5b63ef5d8f6877e17585ff65
parentf4651936468a40242ca3080e6123be903a0a9a62 (diff)
downloadffmpeg-d99234eec2ed3c6445f4673533c3fec9f9f81a07.tar.gz
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> (cherry picked from commit 074e204b42acdacc0a055671481e00914524af93) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/flvdec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 6eb13c7920..75bdb9526e 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
@@ -465,6 +467,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
char str_val[1024];
double num_val;
+ if (depth > MAX_DEPTH)
+ return AVERROR_PATCHWELCOME;
+
num_val = 0;
ioc = s->pb;
if (avio_feof(ioc))