Răsfoiți Sursa

avcodec/sanm: Check w,h,left,top

The setup code fow w,h,left,top is complex, the code using it also falls in
at least 2 different classes, one using left/top the other not.

To ensure no out of array access happens we add this clear check.

Fixes: out of array access
Fixes: 439261995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5383455572819968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 134fbfd1dcb59441e38d870ddd231772f4e8e127)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Michael Niedermayer 3 luni în urmă
părinte
comite
9df90b6a6a
1 a modificat fișierele cu 5 adăugiri și 0 ștergeri
  1. 5 0
      libavcodec/sanm.c

+ 5 - 0
libavcodec/sanm.c

@@ -973,6 +973,11 @@ static int process_frame_obj(SANMVideoContext *ctx)
     }
     }
     bytestream2_skip(&ctx->gb, 4);
     bytestream2_skip(&ctx->gb, 4);
 
 
+    if (w + FFMAX(left, 0) > ctx->avctx->width || h + FFMAX(top, 0) > ctx->avctx->height) {
+        avpriv_request_sample(ctx->avctx, "overly large frame\n");
+        return AVERROR_PATCHWELCOME;
+    }
+
     switch (codec) {
     switch (codec) {
     case 1:
     case 1:
     case 3:
     case 3: