aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-03-02 20:47:57 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-03-08 19:21:49 +0000
commit905172d75c9cfd93c757b09fa4b8afa0e926a13c (patch)
tree7f4c8192e6f5ad9da02e8ded03e9af2d590dca9d
parent8aee35acb1b40e51a4fc8d7f7c561088e25d6d2e (diff)
downloadffmpeg-905172d75c9cfd93c757b09fa4b8afa0e926a13c.tar.gz
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: Anton Khirnov <anton@khirnov.net>
-rw-r--r--libavcodec/webp.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index b98fa4dea4..58f7810793 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -688,6 +688,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 {