riffdec: Add sanity checks for the sample rate

This avoids a division by zero for G726.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit d07aa3f02b)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Martin Storsjö
2013-09-28 23:32:39 +03:00
committed by Luca Barbato
parent 04d2f9ace3
commit 607863acae

View File

@@ -653,6 +653,11 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
if (size > 0) if (size > 0)
avio_skip(pb, size); avio_skip(pb, size);
} }
if (codec->sample_rate <= 0) {
av_log(NULL, AV_LOG_ERROR,
"Invalid sample rate: %d\n", codec->sample_rate);
return AVERROR_INVALIDDATA;
}
codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample); codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
if (codec->codec_id == AV_CODEC_ID_AAC_LATM) { if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {
/* channels and sample_rate values are those prior to applying SBR and/or PS */ /* channels and sample_rate values are those prior to applying SBR and/or PS */