[FFmpeg-devel,3/4] avcodec/iff: Move index use after check in decodeplane8()

Submitted by Michael Niedermayer on Oct. 29, 2019, 10:35 p.m.

Details

Message ID 20191029223505.20667-3-michael@niedermayer.cc
State Accepted
Commit a1f8b36cc45406f66aac635a4db32d2a5cc29f43
Headers show

Commit Message

Michael Niedermayer Oct. 29, 2019, 10:35 p.m.
Fixes: index 9 out of bounds for type 'const uint64_t [8][256]'
Fixes: 18409/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5767030560522240

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

Patch hide | download patch | download mbox

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index c18bac1ea1..3531799c4a 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -456,11 +456,12 @@  static av_cold int decode_init(AVCodecContext *avctx)
  */
 static void decodeplane8(uint8_t *dst, const uint8_t *buf, int buf_size, int plane)
 {
-    const uint64_t *lut = plane8_lut[plane];
+    const uint64_t *lut;
     if (plane >= 8) {
         av_log(NULL, AV_LOG_WARNING, "Ignoring extra planes beyond 8\n");
         return;
     }
+    lut = plane8_lut[plane];
     do {
         uint64_t v = AV_RN64A(dst) | lut[*buf++];
         AV_WN64A(dst, v);