aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-13 17:49:16 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-03 03:00:51 +0100
commite35da91b52cc09d6e4f2a7191cfbc8127e2eda51 (patch)
treec2494e249b909a7e3b330edf8f8af970ddf45195
parent82213d67bad8785aef8806855fd0d291954193df (diff)
downloadffmpeg-e35da91b52cc09d6e4f2a7191cfbc8127e2eda51.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
-rw-r--r--libswresample/swresample.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index b8c646f154..4becb0724d 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -223,6 +223,16 @@ av_cold int swr_init(struct SwrContext *s){
s->flushed = 0;
+ 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-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
return AVERROR(EINVAL);