diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-09-30 23:24:52 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-19 04:36:52 +0200 |
commit | 5c8eb16769e581f828ce420373c558c190185cc1 (patch) | |
tree | 538dc04189f8313b8e2375280274532e0a80c45d /libavcodec/utils.c | |
parent | e23af4662dc667cdb6b7cd297f8cc0160a63e9bf (diff) | |
download | ffmpeg-5c8eb16769e581f828ce420373c558c190185cc1.tar.gz |
avcodec: add codec_whitelist
This allows restricting decoders to a list of needed ones for improved security
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 93be575d27..36ba118e7f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1385,6 +1385,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) goto free_and_end; + if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) { + av_log(avctx, AV_LOG_ERROR, "Codec not on whitelist\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + // only call ff_set_dimensions() for non H.264/VP6F codecs so as not to overwrite previously setup dimensions if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F))) { |