Commit a3541896 authored by Michael Niedermayer's avatar Michael Niedermayer

qdm2: check "AC" codewords

Fixes out of array reads

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 5c8ffbaa
...@@ -824,6 +824,11 @@ static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int le ...@@ -824,6 +824,11 @@ static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int le
} }
} else { } else {
n = get_bits(gb, 8); n = get_bits(gb, 8);
if (n >= 243) {
av_log(NULL, AV_LOG_ERROR, "Invalid 8bit codeword\n");
return AVERROR_INVALIDDATA;
}
for (k = 0; k < 5; k++) for (k = 0; k < 5; k++)
samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]];
} }
...@@ -860,6 +865,11 @@ static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int le ...@@ -860,6 +865,11 @@ static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int le
} }
} else { } else {
n = get_bits (gb, 8); n = get_bits (gb, 8);
if (n >= 243) {
av_log(NULL, AV_LOG_ERROR, "Invalid 8bit codeword\n");
return AVERROR_INVALIDDATA;
}
for (k = 0; k < 5; k++) for (k = 0; k < 5; k++)
samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]];
} }
...@@ -873,6 +883,11 @@ static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int le ...@@ -873,6 +883,11 @@ static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int le
case 24: case 24:
if (get_bits_left(gb) >= 7) { if (get_bits_left(gb) >= 7) {
n = get_bits(gb, 7); n = get_bits(gb, 7);
if (n >= 125) {
av_log(NULL, AV_LOG_ERROR, "Invalid 7bit codeword\n");
return AVERROR_INVALIDDATA;
}
for (k = 0; k < 3; k++) for (k = 0; k < 3; k++)
samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5; samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment