aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-01-31 21:22:11 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-09 13:53:29 +0200
commit4393c27e190a921a6b3b7922435cad8cf6daf6ea (patch)
treeb4ce1910c7c512cf44d44fb0f9e8f73f0d967a93
parent6505b2f7a80a6a10f4f19fbed195d16fc4d350f3 (diff)
downloadffmpeg-4393c27e190a921a6b3b7922435cad8cf6daf6ea.tar.gz
avcodec/ffv1dec: Check if trailer is available
Fixes: out of array read Fixes: 29750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4808377272238080.fuzz 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 36ad2f41e30ad9f2a8ead76e0b1526b9712f0925) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/ffv1dec.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 07933d6f9f..2ff749ffa4 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -893,8 +893,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
int trailer = 3 + 5*!!f->ec;
int v;
- if (i || f->version > 2) v = AV_RB24(buf_p-trailer) + trailer;
- else v = buf_p - c->bytestream_start;
+ if (i || f->version > 2) {
+ if (trailer > buf_p - buf) v = INT_MAX;
+ else v = AV_RB24(buf_p-trailer) + trailer;
+ } else v = buf_p - c->bytestream_start;
if (buf_p - c->bytestream_start < v) {
av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n");
ff_thread_report_progress(&f->picture, INT_MAX, 0);