diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-03-02 22:47:57 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-03 02:37:36 +0300 |
commit | 5de2dab12b951b2fe121eb18503accfc91cd1565 (patch) | |
tree | da399e23e357746e9ed1c4e4cab25dee8ca1f948 | |
parent | da2a49ac9ab55c857fe4116c0996728c49e2be77 (diff) |
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>
-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 e0f7239968..9549c0e37e 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -694,6 +694,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 { |