summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-10-23 00:56:00 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-11-01 11:29:13 -0400
commit0366664ef9af85ee052925f9a1a853d14d2f47a7 (patch)
tree650cb8772361fbf43473d89222525db497b9cd6f /libavcodec/utils.c
parentbb6941af2afd057c3897afb78d034de2c355b8a0 (diff)
lavc: check channel count after decoder init
Ensures the decoder did not set channel count to an insanely high value during initialization, which could cause large memory usage when it tries to get a buffer during decoding.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b4e7ed6b6b..58dfe971e1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -881,6 +881,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
avctx->channel_layout = 0;
}
}
+ if (avctx->channels && avctx->channels < 0 ||
+ avctx->channels > FF_SANE_NB_CHANNELS) {
+ ret = AVERROR(EINVAL);
+ goto free_and_end;
+ }
}
end:
entangled_thread_counter--;