diff mbox series

[FFmpeg-devel,8/8] avcodec/exr: skip bottom clearing loop when its outside the image

Message ID 20201024222312.5806-8-michael@niedermayer.cc
State Accepted
Commit b0a8b40294ea212c1938348ff112ef1b9bf16bb3
Headers show
Series [FFmpeg-devel,1/8] tools/target_dem_fuzzer: Limit max blocks
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 24, 2020, 10:23 p.m. UTC
Fixes: signed integer overflow: 1633771809 * 32960 cannot be represented in type 'int'
Fixes: 26532/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5613925708857344

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

Comments

Michael Niedermayer Nov. 22, 2020, 4:41 p.m. UTC | #1
On Sun, Oct 25, 2020 at 12:23:12AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 1633771809 * 32960 cannot be represented in type 'int'
> Fixes: 26532/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5613925708857344
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/exr.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 25c4f82471..a6435d33a4 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1842,13 +1842,14 @@  static int decode_frame(AVCodecContext *avctx, void *data,
 
     ymax = FFMAX(0, s->ymax + 1);
     // Zero out the end if ymax+1 is not h
-    for (i = 0; i < planes; i++) {
-        ptr = picture->data[i] + (ymax * picture->linesize[i]);
-        for (y = ymax; y < avctx->height; y++) {
-            memset(ptr, 0, out_line_size);
-            ptr += picture->linesize[i];
+    if (ymax < avctx->height)
+        for (i = 0; i < planes; i++) {
+            ptr = picture->data[i] + (ymax * picture->linesize[i]);
+            for (y = ymax; y < avctx->height; y++) {
+                memset(ptr, 0, out_line_size);
+                ptr += picture->linesize[i];
+            }
         }
-    }
 
     picture->pict_type = AV_PICTURE_TYPE_I;
     *got_frame = 1;