diff mbox

[FFmpeg-devel] avcodec/xan: Check for bitstream end in xan_huffman_decode()

Message ID 20171103164829.6970-1-michael@niedermayer.cc
State Accepted
Commit 4b51437dccd62fc5491280db44e3c21b44aeeb3f
Headers show

Commit Message

Michael Niedermayer Nov. 3, 2017, 4:48 p.m. UTC
Fixes: Timeout
Fixes: 3707/clusterfuzz-testcase-6465922706440192

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

Comments

Michael Niedermayer Nov. 4, 2017, 8:07 p.m. UTC | #1
On Fri, Nov 03, 2017 at 05:48:29PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 3707/clusterfuzz-testcase-6465922706440192
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/xan.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

applied

[...]
diff mbox

Patch

diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index 8b4ec82405..1ccf164847 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -131,7 +131,10 @@  static int xan_huffman_decode(uint8_t *dest, int dest_len,
         return ret;
 
     while (val != 0x16) {
-        unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
+        unsigned idx;
+        if (get_bits_left(&gb) < 1)
+            return AVERROR_INVALIDDATA;
+        idx = val - 0x17 + get_bits1(&gb) * byte;
         if (idx >= 2 * byte)
             return AVERROR_INVALIDDATA;
         val = src[idx];