diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-01-23 22:00:40 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-09 13:53:29 +0200 |
commit | 6a3f5c9d76d0b64f1e08b12f6cd4502d092efef7 (patch) | |
tree | 86c0098d934b5a58ef0321b99500e9a759b6876d | |
parent | a280136c7a1cfdce11216ab02b0195d9ce2ce772 (diff) | |
download | ffmpeg-6a3f5c9d76d0b64f1e08b12f6cd4502d092efef7.tar.gz |
avformat/flvdec: Check for nesting depth in amf_skip_tag()
Fixes: out of array access
Fixes: 29440/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5985279812960256.fuzz
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 2ef522c918d48b9f101548b2cadce02003cb3510)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/flvdec.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index fb2d0bac4a..350931cd42 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -802,10 +802,13 @@ static void clear_index_entries(AVFormatContext *s, int64_t pos) } } -static int amf_skip_tag(AVIOContext *pb, AMFDataType type) +static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth) { int nb = -1, ret, parse_name = 1; + if (depth > MAX_DEPTH) + return AVERROR_PATCHWELCOME; + switch (type) { case AMF_DATA_TYPE_NUMBER: avio_skip(pb, 8); @@ -830,7 +833,7 @@ static int amf_skip_tag(AVIOContext *pb, AMFDataType type) } avio_skip(pb, size); } - if ((ret = amf_skip_tag(pb, avio_r8(pb))) < 0) + if ((ret = amf_skip_tag(pb, avio_r8(pb), depth + 1)) < 0) return ret; } break; @@ -874,7 +877,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt, else break; } else { - if ((ret = amf_skip_tag(pb, type)) < 0) + if ((ret = amf_skip_tag(pb, type, 0)) < 0) goto skip; } } |