Browse Source

avcodec/aacsbr: check that the element type matches before applying SBR

Fixes out of array access
Fixes: signal_sigsegv_3670fc0_2818_cov_2307326154_moon.mux

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 79a98294da)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tags/n2.4.11
Michael Niedermayer Michael Niedermayer 10 years ago
parent
commit
514d0e29c8
2 changed files with 9 additions and 0 deletions
  1. +8
    -0
      libavcodec/aacsbr.c
  2. +1
    -0
      libavcodec/sbr.h

+ 8
- 0
libavcodec/aacsbr.c View File

@@ -1018,6 +1018,8 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr,
{ {
unsigned int cnt = get_bits_count(gb); unsigned int cnt = get_bits_count(gb);


sbr->id_aac = id_aac;

if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
if (read_sbr_single_channel_element(ac, sbr, gb)) { if (read_sbr_single_channel_element(ac, sbr, gb)) {
sbr_turnoff(sbr); sbr_turnoff(sbr);
@@ -1688,6 +1690,12 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
int nch = (id_aac == TYPE_CPE) ? 2 : 1; int nch = (id_aac == TYPE_CPE) ? 2 : 1;
int err; int err;


if (id_aac != sbr->id_aac) {
av_log(ac->avctx, AV_LOG_ERROR,
"element type mismatch %d != %d\n", id_aac, sbr->id_aac);
sbr_turnoff(sbr);
}

if (!sbr->kx_and_m_pushed) { if (!sbr->kx_and_m_pushed) {
sbr->kx[0] = sbr->kx[1]; sbr->kx[0] = sbr->kx[1];
sbr->m[0] = sbr->m[1]; sbr->m[0] = sbr->m[1];


+ 1
- 0
libavcodec/sbr.h View File

@@ -137,6 +137,7 @@ typedef struct AACSBRContext {
struct SpectralBandReplication { struct SpectralBandReplication {
int sample_rate; int sample_rate;
int start; int start;
int id_aac;
int reset; int reset;
SpectrumParameters spectrum_params; SpectrumParameters spectrum_params;
int bs_amp_res_header; int bs_amp_res_header;


Loading…
Cancel
Save