aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-12-07 00:37:25 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-09 22:02:20 +0200
commitfe15426edda12b6d8345460f8f7d4be447e84387 (patch)
tree17caa4becd8bb0446e3a26888c474e0d2b597330
parenta4be820f99e2c47c0b44ddd2f6e0dabe85f67c0a (diff)
downloadffmpeg-fe15426edda12b6d8345460f8f7d4be447e84387.tar.gz
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 7b88dd8f0cb48b46f3178d274a9117a3d2307f4e) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/matroskadec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 4427d3936c..448e18a182 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1943,6 +1943,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,