aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-24 19:23:23 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-24 19:23:23 +0200
commit4641ae352ec587355764ffd5c43dd0d0ebd47654 (patch)
treeda175629ebf72bf55a504dd2d0240b1034892f4e /libavformat/utils.c
parente56425d1a71828c32f7f355f0979534e1007078f (diff)
downloadffmpeg-4641ae352ec587355764ffd5c43dd0d0ebd47654.tar.gz
avformat: Add and use ff_copy_whitelists()
Fixes potential security issue in case of running out of memory Found-by: ubitux Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 995bcfc15c..61421c0f29 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -130,6 +130,19 @@ void av_format_inject_global_side_data(AVFormatContext *s)
}
}
+int ff_copy_whitelists(AVFormatContext *dst, AVFormatContext *src)
+{
+ av_assert0(!dst->codec_whitelist && !dst->format_whitelist);
+ dst-> codec_whitelist = av_strdup(src->codec_whitelist);
+ dst->format_whitelist = av_strdup(src->format_whitelist);
+ if ( (src-> codec_whitelist && !dst-> codec_whitelist)
+ || (src->format_whitelist && !dst->format_whitelist)) {
+ av_log(dst, AV_LOG_ERROR, "Failed to duplicate whitelist\n");
+ return AVERROR(ENOMEM);
+ }
+ return 0;
+}
+
static const AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
{
if (st->codec->codec)