1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/ac3dec: Check channel_map index

Fixes: out of array read
Fixes: 8924/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EAC3_fuzzer-5851861780267008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2018-06-27 15:56:18 +02:00
parent bd27a9364c
commit 00f98d23b1

View File

@ -1690,6 +1690,7 @@ dependent_frame:
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) { if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
uint64_t ich_layout = avpriv_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON]; uint64_t ich_layout = avpriv_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON];
int channel_map_size = ff_ac3_channels_tab[s->output_mode & ~AC3_OUTPUT_LFEON] + s->lfe_on;
uint64_t channel_layout; uint64_t channel_layout;
int extend = 0; int extend = 0;
@ -1718,6 +1719,9 @@ dependent_frame:
custom_channel_map_locations[ch][1]); custom_channel_map_locations[ch][1]);
if (index < 0) if (index < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (extend >= channel_map_size)
return AVERROR_INVALIDDATA;
extended_channel_map[index] = offset + channel_map[extend++]; extended_channel_map[index] = offset + channel_map[extend++];
} else { } else {
int i; int i;
@ -1728,6 +1732,9 @@ dependent_frame:
1LL << i); 1LL << i);
if (index < 0) if (index < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (extend >= channel_map_size)
return AVERROR_INVALIDDATA;
extended_channel_map[index] = offset + channel_map[extend++]; extended_channel_map[index] = offset + channel_map[extend++];
} }
} }