aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-12-17 00:19:42 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-01-06 15:03:15 +0100
commitf8dc85589e419e8be61ad4dd3fb4f955be135ad9 (patch)
treed23657168cc14af6f5f4c9d0bb1f1e1e10abe55c
parent332f7a4c0086348820d288a91753237bada762d7 (diff)
downloadffmpeg-f8dc85589e419e8be61ad4dd3fb4f955be135ad9.tar.gz
avcodec/atrac9dec: Clamp band_ext_data to max that can be read if skipped.
Fixes: out of array read Fixes: 19327/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5679823087468544 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 18ff210efb8d158f3e8c79508d99a52eaebf9d48) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/atrac9dec.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index 1586e85f26..061f2e7ceb 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -226,8 +226,18 @@ static inline int parse_band_ext(ATRAC9Context *s, ATRAC9BlockData *b,
b->channel[0].band_ext = get_bits(gb, 2);
b->channel[0].band_ext = ext_band > 2 ? b->channel[0].band_ext : 4;
- if (!get_bits(gb, 5))
+ if (!get_bits(gb, 5)) {
+ for (int i = 0; i <= stereo; i++) {
+ ATRAC9ChannelData *c = &b->channel[i];
+ const int count = at9_tab_band_ext_cnt[c->band_ext][ext_band];
+ for (int j = 0; j < count; j++) {
+ int len = at9_tab_band_ext_lengths[c->band_ext][ext_band][j];
+ c->band_ext_data[j] = av_clip_uintp2_c(c->band_ext_data[j], len);
+ }
+ }
+
return 0;
+ }
for (int i = 0; i <= stereo; i++) {
ATRAC9ChannelData *c = &b->channel[i];