Skip to content

Commit 6646dd2

Browse files
committed
avcodec/aac/aacdec_lpd: Limit get_unary()
The limit is based on later code storing 32bits Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Fixes: 393164866/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-4606798354513920 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 464fb86) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
1 parent bf8c0be commit 6646dd2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

libavcodec/aac/aacdec_lpd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void parse_qn(GetBitContext *gb, int *qn, int nk_mode, int no_qn)
6262
{
6363
if (nk_mode == 1) {
6464
for (int k = 0; k < no_qn; k++) {
65-
qn[k] = get_unary(gb, 0, INT32_MAX); // TODO: find proper ranges
65+
qn[k] = get_unary(gb, 0, 68); // TODO: find proper ranges
6666
if (qn[k])
6767
qn[k]++;
6868
}
@@ -75,7 +75,7 @@ static void parse_qn(GetBitContext *gb, int *qn, int nk_mode, int no_qn)
7575
if (nk_mode == 2) {
7676
for (int k = 0; k < no_qn; k++) {
7777
if (qn[k] > 4) {
78-
qn[k] = get_unary(gb, 0, INT32_MAX);;
78+
qn[k] = get_unary(gb, 0, 65);
7979
if (qn[k])
8080
qn[k] += 4;
8181
}
@@ -85,7 +85,7 @@ static void parse_qn(GetBitContext *gb, int *qn, int nk_mode, int no_qn)
8585

8686
for (int k = 0; k < no_qn; k++) {
8787
if (qn[k] > 4) {
88-
int qn_ext = get_unary(gb, 0, INT32_MAX);;
88+
int qn_ext = get_unary(gb, 0, 65);
8989
switch (qn_ext) {
9090
case 0: qn[k] = 5; break;
9191
case 1: qn[k] = 6; break;
@@ -114,6 +114,9 @@ static int parse_codebook_idx(GetBitContext *gb, uint32_t *kv,
114114
}
115115
}
116116

117+
if (nk > 25)
118+
return AVERROR_PATCHWELCOME;
119+
117120
skip_bits(gb, 4*n);
118121

119122
if (nk > 0)

0 commit comments

Comments
 (0)