diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-03-02 20:47:57 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-09 12:58:39 +0100 |
commit | b55be8b266761bbef6d39195ad7bb3bfd953c4f0 (patch) | |
tree | b04f962015399832fb807d317b7aa059024c19cf | |
parent | fc6a00d20d025a1c71ebcd4953b064f37156afaa (diff) | |
download | ffmpeg-b55be8b266761bbef6d39195ad7bb3bfd953c4f0.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 0355cb6eab..e06680cbeb 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -690,6 +690,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 { |