]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/dxtory: Fix get_raw_size() for YUV
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 25 Sep 2020 15:07:24 +0000 (17:07 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 26 Sep 2020 17:32:42 +0000 (19:32 +0200)
Fixes: out of array read
Fixes: 25455/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-6327985731534848
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dxtory.c

index 3f3c23ff2a748ade6e16537e08769c69ec93534a..157e4b3ed2f8b8a5b44523357d4756243ef556a4 100644 (file)
@@ -44,9 +44,9 @@ static int64_t get_raw_size(enum AVPixelFormat fmt, int width, int height)
     case AV_PIX_FMT_YUV444P:
         return width * height * 3LL;
     case AV_PIX_FMT_YUV420P:
-        return (int64_t)(width * height) + AV_CEIL_RSHIFT(width, 1) * AV_CEIL_RSHIFT(height, 1);
+        return (int64_t)(width * height) + 2 * AV_CEIL_RSHIFT(width, 1) * AV_CEIL_RSHIFT(height, 1);
     case AV_PIX_FMT_YUV410P:
-        return (int64_t)(width * height) + AV_CEIL_RSHIFT(width, 2) * AV_CEIL_RSHIFT(height, 2);
+        return (int64_t)(width * height) + 2 * AV_CEIL_RSHIFT(width, 2) * AV_CEIL_RSHIFT(height, 2);
     }
 
     return 0;