[FFmpeg-devel,1/5] avcodec/parser: Check next index validity in ff_combine_frame()

Submitted by Michael Niedermayer on July 6, 2019, 10:57 a.m.

Details

Message ID 20190706105749.11410-1-michael@niedermayer.cc
State Accepted
Commit 15008db0fac6d97bb939fa7ef9e92d79bf1f7cb1
Headers show

Commit Message

Michael Niedermayer July 6, 2019, 10:57 a.m.
Fixes: out of array access
Fixes: 15522/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DNXHD_fuzzer-5747756078989312

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

Comments

Michael Niedermayer July 17, 2019, 9:18 p.m.
On Sat, Jul 06, 2019 at 12:57:45PM +0200, Michael Niedermayer wrote:
> Fixes: out of array access
> Fixes: 15522/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DNXHD_fuzzer-5747756078989312
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/parser.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply patchset

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 0a994a3f30..3e19810a94 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -245,6 +245,9 @@  int ff_combine_frame(ParseContext *pc, int next,
     for (; pc->overread > 0; pc->overread--)
         pc->buffer[pc->index++] = pc->buffer[pc->overread_index++];
 
+    if (next > *buf_size)
+        return AVERROR(EINVAL);
+
     /* flush remaining if EOF */
     if (!*buf_size && next == END_NOT_FOUND)
         next = 0;