[FFmpeg-devel] avcodec/lzw: Check for end of input

Submitted by Michael Niedermayer on Jan. 11, 2019, 10:46 p.m.

Details

Message ID 20190111224611.6725-1-michael@niedermayer.cc
State Accepted
Commit 19dc5cdaa7c4a0e62c30497814417ffe77fb2ed7
Headers show

Commit Message

Michael Niedermayer Jan. 11, 2019, 10:46 p.m.
Fixes: Timeout
Fixes: 11873/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5093495044308992

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

Comments

Michael Niedermayer Jan. 15, 2019, 9:26 p.m.
On Fri, Jan 11, 2019 at 11:46:11PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 11873/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5093495044308992
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/lzw.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c
index b0b9a34358..e26e4829ee 100644
--- a/libavcodec/lzw.c
+++ b/libavcodec/lzw.c
@@ -71,6 +71,9 @@  static int lzw_get_code(struct LZWState * s)
 {
     int c;
 
+    if (s->bbits < s->cursize && bytestream2_get_bytes_left(&s->gb) <= 0)
+        return s->end_code;
+
     if(s->mode == FF_LZW_GIF) {
         while (s->bbits < s->cursize) {
             if (!s->bs) {