1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

twinvq: validate sample rate code

A large invalid value could cause undefined behavior when left-shifted
by 8 later in the function.
This commit is contained in:
Justin Ruggles 2012-10-23 13:17:50 -04:00
parent 335826cf5f
commit b5f628e227

View File

@ -1120,6 +1120,11 @@ static av_cold int twin_decode_init(AVCodecContext *avctx)
avctx->channels = AV_RB32(avctx->extradata ) + 1; avctx->channels = AV_RB32(avctx->extradata ) + 1;
avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000; avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000;
isampf = AV_RB32(avctx->extradata + 8); 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) { switch (isampf) {
case 44: avctx->sample_rate = 44100; break; case 44: avctx->sample_rate = 44100; break;
case 22: avctx->sample_rate = 22050; break; case 22: avctx->sample_rate = 22050; break;