diff mbox series

[FFmpeg-devel,2/2] avcodec/webp: Check available space in loop in decode_entropy_coded_image()

Message ID 20210725140155.9115-2-michael@niedermayer.cc
State Accepted
Commit 5e00eab61112c52f27a09fe77d50e6fc508f9c53
Headers show
Series [FFmpeg-devel,1/2] tools/target_dec_fuzzer: Adjust threshold for VP6F
Related show

Checks

Context Check Description
andriy/configure warning Failed to apply patch
andriy/configure warning Failed to apply patch

Commit Message

Michael Niedermayer July 25, 2021, 2:01 p.m. UTC
Fixes: Timeout
Fixes: 35401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5714401821851648

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

Comments

Michael Niedermayer Aug. 22, 2021, 3:54 p.m. UTC | #1
On Sun, Jul 25, 2021 at 04:01:55PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 35401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5714401821851648
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/webp.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 83371ef6fd..3efd4438d9 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -627,6 +627,9 @@  static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role,
     while (y < img->frame->height) {
         int v;
 
+        if (get_bits_left(&s->gb) < 0)
+            return AVERROR_INVALIDDATA;
+
         hg = get_huffman_group(s, img, x, y);
         v = huff_reader_get_symbol(&hg[HUFF_IDX_GREEN], &s->gb);
         if (v < NUM_LITERAL_CODES) {