[FFmpeg-cvslog] avformat/webmdashenc: Check codec types

Andreas Rheinhardt git at videolan.org
Fri Jul 3 20:29:45 EEST 2020


ffmpeg | branch: release/3.2 | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Mon Mar 30 02:50:02 2020 +0200| [939cb37247f23d738893efdb9f58f62b7c87001c] | committer: Andreas Rheinhardt

avformat/webmdashenc: Check codec types

The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus,
but there was no check for this. The codec type is used to get a pointer
to a string containing the codec name or NULL if it is not one of those
four codecs. Said pointer has then been used without further checks as
string for the %s conversion specifier in an avio_printf()) call which
is undefined behaviour.

This commit adds a check for the supported codec types.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
(cherry picked from commit cbea58b2b35c6409e062c929f0b2ab763b8661eb)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=939cb37247f23d738893efdb9f58f62b7c87001c
---

 libavformat/webmdashenc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index a16b437417..c392dbb5e8 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -490,6 +490,14 @@ static int webm_dash_manifest_write_header(AVFormatContext *s)
     double start = 0.0;
     int ret;
     WebMDashMuxContext *w = s->priv_data;
+
+    for (unsigned i = 0; i < s->nb_streams; i++) {
+        enum AVCodecID codec_id = s->streams[i]->codecpar->codec_id;
+        if (codec_id != AV_CODEC_ID_VP8    && codec_id != AV_CODEC_ID_VP9 &&
+            codec_id != AV_CODEC_ID_VORBIS && codec_id != AV_CODEC_ID_OPUS)
+            return AVERROR(EINVAL);
+    }
+
     ret = parse_adaptation_sets(s);
     if (ret < 0) {
         goto fail;



More information about the ffmpeg-cvslog mailing list