avcodec/ffv1dec: Fix out of array read in slice counting
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 9 Oct 2017 09:49:28 +0000 (11:49 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 10 Oct 2017 21:58:41 +0000 (23:58 +0200)
Fixes: test-201710.mp4

Found-by: 连一汉 <lianyihan@360.cn> and Zhibin Hu
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/ffv1dec.c

index d2bfee7..5eadb6b 100644 (file)
@@ -717,7 +717,7 @@ static int read_header(FFV1Context *f)
     } else {
         const uint8_t *p = c->bytestream_end;
         for (f->slice_count = 0;
-             f->slice_count < MAX_SLICES && 3 < p - c->bytestream_start;
+             f->slice_count < MAX_SLICES && 3 + 5*!!f->ec < p - c->bytestream_start;
              f->slice_count++) {
             int trailer = 3 + 5*!!f->ec;
             int size = AV_RB24(p-trailer);