diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-01-23 21:20:57 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-10 16:04:26 +0200 |
commit | 3db1c93b5cba6bed2681acc36eaeec05ebcf7621 (patch) | |
tree | 8dd76bb0fdfad5a80e47b484efdb11ce2f8bbe74 /libavformat | |
parent | 6cd5bfe3cdfbc5c85b4946c6f0537195ec9f501b (diff) | |
download | ffmpeg-3db1c93b5cba6bed2681acc36eaeec05ebcf7621.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')
-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 6dce9b8dcd..01c845f58d 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -42,6 +42,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 @@ -494,6 +496,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)) |