diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 17:49:16 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-19 01:31:25 +0100 |
commit | 7c40a0449b4771a0a09c3c38e081d3869d1f917b (patch) | |
tree | 917407d06dd6b4e8178753c2aa3d7c822404790d | |
parent | 811a504c6bc2586a8ea5d52fbcfee94277123eb5 (diff) | |
download | ffmpeg-7c40a0449b4771a0a09c3c38e081d3869d1f917b.tar.gz |
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>
(cherry picked from commit 21cd905cd44a4bbafe8631bbaa6021d328413ce5)
Conflicts:
libswresample/swresample.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-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 f530c1f59e..e93f707390 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -249,6 +249,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; + } + if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){ if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){ s->int_sample_fmt= AV_SAMPLE_FMT_S16P; |