diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-03-02 20:47:57 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-22 12:27:23 +0200 |
commit | 3f5a2831744c3e55261ca5e2a6d05f7a87143b33 (patch) | |
tree | 09c3ca1b33a71e58e33b03f9d000924a158a1b60 | |
parent | 66a1ed96bf3d5a6755a24769f29075618ec6131a (diff) | |
download | ffmpeg-3f5a2831744c3e55261ca5e2a6d05f7a87143b33.tar.gz |
avcodec/webp: validate the distance prefix code
According to the WebP Lossless Bitstream Specification the highest
allowed value for a prefix code is 39.
If prefix_code is too large, the calculated extra_bits has an invalid
value and triggers an assertion in get_bits.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 5de2dab12b951b2fe121eb18503accfc91cd1565)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/webp.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 931fdc50b3..b78822c6bb 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -668,6 +668,11 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role, length = offset + get_bits(&s->gb, extra_bits) + 1; } prefix_code = huff_reader_get_symbol(&hg[HUFF_IDX_DIST], &s->gb); + if (prefix_code > 39) { + av_log(s->avctx, AV_LOG_ERROR, + "distance prefix code too large: %d\n", prefix_code); + return AVERROR_INVALIDDATA; + } if (prefix_code < 4) { distance = prefix_code + 1; } else { |