aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-11-03 17:48:29 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-01-08 23:19:14 +0100
commitd7c29005a40fbc7f46075a639219d7341fbe2c09 (patch)
treea27e463aaaf5349307bde2fc5f142bc0b188cd66
parent8b8502a66f00a0e2ae186d1edd3eeb2ef1eb6bd3 (diff)
downloadffmpeg-d7c29005a40fbc7f46075a639219d7341fbe2c09.tar.gz
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@niedermayer.cc> (cherry picked from commit 4b51437dccd62fc5491280db44e3c21b44aeeb3f) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/xan.c5
1 files changed, 4 insertions, 1 deletions
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];