[FFmpeg-devel] [PATCH 1/2] matroskadec: check audio sample rate

Michael Niedermayer michaelni at gmx.at
Tue Jun 16 02:16:26 CEST 2015


On Mon, Jun 15, 2015 at 09:17:36PM +0200, Andreas Cadhalpun wrote:
> And default to 8000 if it is invalid.
> 
> An invalid sample rate can trigger av_assert2 in av_rescale_rnd.
> 
> 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;
> +        }
> +

LGTM, alternatively the sample rate could be set to 0

Thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150616/3eab7343/attachment.asc>


More information about the ffmpeg-devel mailing list