diff mbox series

[FFmpeg-devel,2/4] avformat/thp: Check compcount

Message ID 20200531135020.5675-2-michael@niedermayer.cc
State Accepted
Commit 1ba8484559661dfdbca36dbc17b203f33f62e26c
Headers show
Series [FFmpeg-devel,1/4] avcodec/jpeg2000dec: clear pointer which become stale in get_ppt() | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer May 31, 2020, 1:50 p.m. UTC
Fixes: out of array access
Fixes: 22520/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5100297658826752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/thp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Michael Niedermayer June 7, 2020, 8:30 p.m. UTC | #1
On Sun, May 31, 2020 at 03:50:18PM +0200, Michael Niedermayer wrote:
> Fixes: out of array access
> Fixes: 22520/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5100297658826752
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/thp.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/thp.c b/libavformat/thp.c
index d3ae86c645..4abff1313a 100644
--- a/libavformat/thp.c
+++ b/libavformat/thp.c
@@ -93,6 +93,9 @@  static int thp_read_header(AVFormatContext *s)
     avio_seek (pb, thp->compoff, SEEK_SET);
     thp->compcount       = avio_rb32(pb);
 
+    if (thp->compcount > FF_ARRAY_ELEMS(thp->components))
+        return AVERROR_INVALIDDATA;
+
     /* Read the list of component types.  */
     avio_read(pb, thp->components, 16);