diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-01-23 21:20:57 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-10-17 21:34:53 +0200 |
commit | 01cd33e59f45a88b4057d9ffbae63e52c375325f (patch) | |
tree | ebd4c7c6109e80bf41dd7c05412e74000e6f0f9a /libavformat/flvdec.c | |
parent | e4bae4cb70835bd70c7d745a495e4e11e5cd2f44 (diff) | |
download | ffmpeg-01cd33e59f45a88b4057d9ffbae63e52c375325f.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>
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r-- | libavformat/flvdec.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 7b5ce983a8..89feb6f106 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -39,6 +39,8 @@ #define VALIDATE_INDEX_TS_THRESH 2500 +#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 @@ -393,6 +395,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)) |