[FFmpeg-devel,1/3] avcodec/bintext: Check input size before allocating the input image

Submitted by Michael Niedermayer on Sept. 12, 2018, 1:08 a.m.

Details

Message ID 20180912010808.31637-1-michael@niedermayer.cc
State Accepted
Commit 8db9097308dcc72f3f1f459a2b39f7a987ddd978
Headers show

Commit Message

Michael Niedermayer Sept. 12, 2018, 1:08 a.m.
Fixes: Timeout
Fixes: 9795/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XBIN_fuzzer-5768631928487936

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

Comments

Michael Niedermayer Sept. 28, 2018, 12:12 a.m.
On Wed, Sep 12, 2018 at 03:08:06AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 9795/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XBIN_fuzzer-5768631928487936
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/bintext.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c
index d967317671..b14a2a9c29 100644
--- a/libavcodec/bintext.c
+++ b/libavcodec/bintext.c
@@ -146,6 +146,9 @@  static int decode_frame(AVCodecContext *avctx,
     const uint8_t *buf_end = buf+buf_size;
     int ret;
 
+    if ((avctx->width / FONT_WIDTH) * (avctx->height / s->font_height) / 256 > buf_size)
+        return AVERROR_INVALIDDATA;
+
     s->x = s->y = 0;
     if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
         return ret;