diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 20:49:16 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 20:50:24 +0400 |
commit | 21cd905cd44a4bbafe8631bbaa6021d328413ce5 (patch) | |
tree | baa3006bb681c2ddbdf070ec2b71d269afbd0a9e /libswresample | |
parent | 34126cd090c38250b3002169843d60f4e4c3beb6 (diff) |
swr: check channel layouts before using them.
Fixes out of array accesses
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample')
-rw-r--r-- | libswresample/swresample.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c index b192bfdfa9..9c2e3f5000 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -265,6 +265,16 @@ av_cold int swr_init(struct SwrContext *s){ return AVERROR(EINVAL); } + if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) { + av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout); + s->in_ch_layout = 0; + } + + if(av_get_channel_layout_nb_channels(s->out_ch_layout) > SWR_CH_MAX) { + av_log(s, AV_LOG_WARNING, "Output channel layout 0x%"PRIx64" is invalid or unsupported.\n", s->out_ch_layout); + s->out_ch_layout = 0; + } + switch(s->engine){ #if CONFIG_LIBSOXR extern struct Resampler const soxr_resampler; |