diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-02-04 15:17:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-02-04 15:17:29 +0100 |
commit | 5144d919964f050d953b9dbe6910fb5388a1965d (patch) | |
tree | d3b1572323ff2f1ddd452293620558106c08232b /libavformat | |
parent | 40fc1e2dda7b7695702a0e8669aa9429f88b593b (diff) | |
parent | 7b03b65bf0d02519c86750d2da33f413e11cf0c6 (diff) | |
download | ffmpeg-5144d919964f050d953b9dbe6910fb5388a1965d.tar.gz |
Merge commit '7b03b65bf0d02519c86750d2da33f413e11cf0c6'
* commit '7b03b65bf0d02519c86750d2da33f413e11cf0c6':
lavf: do basic sanity checking on muxed packets
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mux.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index 70b60640a1..aebfe2c8f7 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -557,10 +557,33 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return ret; } +static int check_packet(AVFormatContext *s, AVPacket *pkt) +{ + if (!pkt) + return 0; + + if (pkt->stream_index < 0 || pkt->stream_index >= s->nb_streams) { + av_log(s, AV_LOG_ERROR, "Invalid packet stream index: %d\n", + pkt->stream_index); + return AVERROR(EINVAL); + } + + if (s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) { + av_log(s, AV_LOG_ERROR, "Received a packet for an attachment stream.\n"); + return AVERROR(EINVAL); + } + + return 0; +} + int av_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret; + ret = check_packet(s, pkt); + if (ret < 0) + return ret; + if (!pkt) { if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { ret = s->oformat->write_packet(s, NULL); @@ -770,6 +793,10 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret, flush = 0; + ret = check_packet(s, pkt); + if (ret < 0) + return ret; + if (pkt) { AVStream *st = s->streams[pkt->stream_index]; |