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

Michael Niedermayer git at videolan.org
Thu Feb 1 01:51:11 EET 2018


ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Fri Nov  3 17:48:29 2017 +0100| [1376beb658d3a4bac3ec6b317332c734ec4a2460] | committer: Michael Niedermayer

avcodec/xan: Check for bitstream end in xan_huffman_decode()

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 at niedermayer.cc>
(cherry picked from commit 4b51437dccd62fc5491280db44e3c21b44aeeb3f)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1376beb658d3a4bac3ec6b317332c734ec4a2460
---

 libavcodec/xan.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index 85fa8e7394..cafcbed9dc 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -130,7 +130,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];



More information about the ffmpeg-cvslog mailing list