avformat/matroskadec: Sanity check codec_id/track type

Fixes: memleak
Fixes: 27766/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5198300814508032

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7b88dd8f0c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-12-07 00:37:25 +01:00
parent 9ea488e0fb
commit 35076c8f63
1 changed files with 9 additions and 0 deletions

View File

@ -2322,6 +2322,15 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (!track->codec_id)
continue;
if ( track->type == MATROSKA_TRACK_TYPE_AUDIO && track->codec_id[0] != 'A'
|| track->type == MATROSKA_TRACK_TYPE_VIDEO && track->codec_id[0] != 'V'
|| track->type == MATROSKA_TRACK_TYPE_SUBTITLE && track->codec_id[0] != 'D' && track->codec_id[0] != 'S'
|| track->type == MATROSKA_TRACK_TYPE_METADATA && track->codec_id[0] != 'D' && track->codec_id[0] != 'S'
) {
av_log(matroska->ctx, AV_LOG_INFO, "Inconsistent track type\n");
continue;
}
if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX ||
isnan(track->audio.samplerate)) {
av_log(matroska->ctx, AV_LOG_WARNING,