summaryrefslogtreecommitdiff
path: root/libavcodec/twinvq.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-10-23 13:17:50 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-11-01 11:29:19 -0400
commitb5f628e227743fc1725a28b5b21f538a40efca82 (patch)
tree218a7bde58a7b94a75531fdf535043bf55173d9a /libavcodec/twinvq.c
parent335826cf5f7169199ed0a8d3a61f697ec0438d30 (diff)
twinvq: validate sample rate code
A large invalid value could cause undefined behavior when left-shifted by 8 later in the function.
Diffstat (limited to 'libavcodec/twinvq.c')
-rw-r--r--libavcodec/twinvq.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index 3159e498e7..7af370ee5a 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -1120,6 +1120,11 @@ static av_cold int twin_decode_init(AVCodecContext *avctx)
avctx->channels = AV_RB32(avctx->extradata ) + 1;
avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000;
isampf = AV_RB32(avctx->extradata + 8);
+
+ if (isampf < 8 || isampf > 44) {
+ av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate\n");
+ return AVERROR_INVALIDDATA;
+ }
switch (isampf) {
case 44: avctx->sample_rate = 44100; break;
case 22: avctx->sample_rate = 22050; break;