Only "succeed" to read a header if the codec is valid. Otherwise return AVERROR_INVALIDDATA. --- libavformat/oggparseogm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c index a07453760b..e71298d39a 100644 --- a/libavformat/oggparseogm.c +++ b/libavformat/oggparseogm.c @@ -24,9 +24,9 @@ #include <stdlib.h> -#include "libavutil/intreadwrite.h" - +#include "libavcodec/avcodec.h" #include "libavcodec/bytestream.h" +#include "libavutil/intreadwrite.h" #include "avformat.h" #include "internal.h" @@ -58,6 +58,8 @@ ogm_header(AVFormatContext *s, int idx) tag = bytestream2_get_le32(&p); st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag); st->codecpar->codec_tag = tag; + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + return AVERROR_INVALIDDATA; if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4) st->need_parsing = AVSTREAM_PARSE_HEADERS; } else if (bytestream2_peek_byte(&p) == 't') { @@ -73,6 +75,8 @@ ogm_header(AVFormatContext *s, int idx) acid[4] = 0; cid = strtol(acid, NULL, 16); st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + return AVERROR_INVALIDDATA; // our parser completely breaks AAC in Ogg if (st->codecpar->codec_id != AV_CODEC_ID_AAC) st->need_parsing = AVSTREAM_PARSE_FULL; @@ -147,6 +151,8 @@ ogm_dshow_header(AVFormatContext *s, int idx) st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(p + 68)); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + return AVERROR_INVALIDDATA; avpriv_set_pts_info(st, 64, AV_RL64(p + 164), 10000000); st->codecpar->width = AV_RL32(p + 176); st->codecpar->height = AV_RL32(p + 180); @@ -156,6 +162,8 @@ ogm_dshow_header(AVFormatContext *s, int idx) st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, AV_RL16(p + 124)); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + return AVERROR_INVALIDDATA; st->codecpar->channels = AV_RL16(p + 126); st->codecpar->sample_rate = AV_RL32(p + 128); st->codecpar->bit_rate = AV_RL32(p + 132) * 8; -- 2.22.0.rc2.383.gf4fbbf30c2-goog _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".