summaryrefslogtreecommitdiff
path: root/libavcodec/eac3dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-06-27 14:43:39 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-09-22 00:12:27 +0200
commitfe315feab59f2f99765547096357826bc9454d24 (patch)
tree68858786dc19b3219b050f4ee0c27d0acfa0ffba /libavcodec/eac3dec.c
parenta068594248b784c97d4423812379ca03c6ce5c54 (diff)
avcodec/eac3dec: Check that channel_map does not contain more than EAC3_MAX_CHANNELS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/eac3dec.c')
-rw-r--r--libavcodec/eac3dec.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index fe97d29032..73067ded9d 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -349,8 +349,18 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
/* dependent stream channel map */
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
if (get_bits1(gbc)) {
- s->channel_map = get_bits(gbc, 16);
- av_log(s->avctx, AV_LOG_DEBUG, "channel_map: %0X\n", s->channel_map);
+ int64_t channel_layout = 0;
+ int channel_map = get_bits(gbc, 16);
+ av_log(s->avctx, AV_LOG_DEBUG, "channel_map: %0X\n", channel_map);
+
+ for (i = 0; i < 16; i++)
+ if (channel_map & (1 << (EAC3_MAX_CHANNELS - i - 1)))
+ channel_layout |= ff_eac3_custom_channel_map_locations[i][1];
+
+ if (av_popcount64(channel_layout) > EAC3_MAX_CHANNELS) {
+ return AVERROR_INVALIDDATA;
+ }
+ s->channel_map = channel_map;
}
}