[FFmpeg-devel] [libav-devel] [PATCH 1/2] matroskadec: check audio sample rate
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Tue Jun 16 00:12:24 CEST 2015
On 15.06.2015 21:42, Luca Barbato wrote:
> On 15/06/15 21:17, Andreas Cadhalpun wrote:
>> And default to 8000 if it is invalid.
>>
>> An invalid sample rate can trigger av_assert2 in av_rescale_rnd.
>
> No, it cannot.
That depends.
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
>> ---
>> libavformat/matroskadec.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 3512f0f..81dd53f 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -1680,6 +1680,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
>> if (!track->codec_id)
>> continue;
>>
>> + if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX ||
>> + isnan(track->audio.samplerate)) {
>> + av_log(matroska->ctx, AV_LOG_WARNING,
>> + "Invalid sample rate %f, defaulting to 8000 instead.\n",
>> + track->audio.samplerate);
>> + track->audio.samplerate = 8000;
>> + }
>
> How can you get an invalid value here to begin with?
It gets read during ebml_parse.
> Replacing an
> invalid value with a made-up value doesn't sound right.
Well, 8000 is the default for MATROSKA_ID_AUDIOSAMPLINGFREQ.
Best regards,
Andreas
More information about the ffmpeg-devel
mailing list