diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-03-05 22:48:28 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-03-19 21:03:13 +0100 |
commit | 30e6abd1a8cc4fd5daf2e23ad2e768862c39e975 (patch) | |
tree | f48a3264d92314a88a09d739875912e95f18644e /libavcodec/webp.c | |
parent | cf18e777aed9f73011c7ab7cbab8003189d4b9d8 (diff) | |
download | ffmpeg-30e6abd1a8cc4fd5daf2e23ad2e768862c39e975.tar.gz |
webp: ensure that each transform is only used once
According to the WebP Lossless Bitstream Specification
"each transform is allowed to be used only once".
If a transform is more than once this can lead to memory
corruption.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/webp.c')
-rw-r--r-- | libavcodec/webp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 58f7810793..62f35f7480 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1081,7 +1081,7 @@ static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p, unsigned int data_size, int is_alpha_chunk) { WebPContext *s = avctx->priv_data; - int w, h, ret, i; + int w, h, ret, i, used; if (!is_alpha_chunk) { s->lossless = 1; @@ -1131,9 +1131,17 @@ static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p, /* parse transformations */ s->nb_transforms = 0; s->reduced_width = 0; + used = 0; while (get_bits1(&s->gb)) { enum TransformType transform = get_bits(&s->gb, 2); s->transforms[s->nb_transforms++] = transform; + if (used & (1 << transform)) { + av_log(avctx, AV_LOG_ERROR, "Transform %d used more than once\n", + transform); + ret = AVERROR_INVALIDDATA; + goto free_and_return; + } + used |= (1 << transform); switch (transform) { case PREDICTOR_TRANSFORM: ret = parse_transform_predictor(s); |