]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/rawdec: Use linesize in b64a
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 1 Jan 2020 21:32:04 +0000 (22:32 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 30 Jan 2020 18:57:25 +0000 (19:57 +0100)
Fixes: out of array access
Fixes: 19750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RAWVIDEO_fuzzer-5074834119983104
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/rawdec.c

index 0b2d8708e6e4d68683dc7f00edb5f86f0161d2b1..a110a690f574c65a8f93bf0b98b564b26a40b475 100644 (file)
@@ -467,10 +467,13 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
         avctx->pix_fmt   == AV_PIX_FMT_RGBA64BE) {
         uint8_t *dst = frame->data[0];
         uint64_t v;
-        int x;
-        for (x = 0; x >> 3 < avctx->width * avctx->height; x += 8) {
-            v = AV_RB64(&dst[x]);
-            AV_WB64(&dst[x], v << 16 | v >> 48);
+        int x, y;
+        for (y = 0; y < avctx->height; y++) {
+            for (x = 0; x >> 3 < avctx->width; x += 8) {
+                v = AV_RB64(&dst[x]);
+                AV_WB64(&dst[x], v << 16 | v >> 48);
+            }
+            dst += frame->linesize[0];
         }
     }