diff mbox series

[FFmpeg-devel,5/8] avcodec/cri: Stop the bitreader at the end of uncompressed input

Message ID 20210201223116.11378-5-michael@niedermayer.cc
State Accepted
Commit 497e7473877243ff8ae02d8701aaf7854b9b57bf
Headers show
Series [FFmpeg-devel,1/8] avcodec/cbs_sei_syntax_template: Check for non negativity before setting size_t bits_left
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Feb. 1, 2021, 10:31 p.m. UTC
Fixes: Timeout
Fixes: 29983/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-6420415838814208

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

Comments

Michael Niedermayer Feb. 22, 2021, 4:53 p.m. UTC | #1
On Mon, Feb 01, 2021 at 11:31:13PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 29983/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-6420415838814208
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/cri.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index f7c3b4ef48..2d33b54e42 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -331,6 +331,9 @@  skip:
         for (int y = 0; y < avctx->height; y++) {
             uint16_t *dst = (uint16_t *)(p->data[0] + y * p->linesize[0]);
 
+            if (get_bits_left(&gbit) < avctx->width * bps)
+                break;
+
             for (int x = 0; x < avctx->width; x++)
                 dst[x] = get_bits(&gbit, bps) << shift;
         }