Commit 6535d81d authored by Michael Niedermayer's avatar Michael Niedermayer

g723_1dec: Fix lsp2lpc() so it can handle values at the ends of the table.

Fixes out of array reads

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 2207ea44
...@@ -359,7 +359,7 @@ static void lsp2lpc(int16_t *lpc) ...@@ -359,7 +359,7 @@ static void lsp2lpc(int16_t *lpc)
/* Calculate negative cosine */ /* Calculate negative cosine */
for (j = 0; j < LPC_ORDER; j++) { for (j = 0; j < LPC_ORDER; j++) {
int index = lpc[j] >> 7; int index = (lpc[j] >> 7) & 0x1FF;
int offset = lpc[j] & 0x7f; int offset = lpc[j] & 0x7f;
int temp1 = cos_tab[index] << 16; int temp1 = cos_tab[index] << 16;
int temp2 = (cos_tab[index + 1] - cos_tab[index]) * int temp2 = (cos_tab[index + 1] - cos_tab[index]) *
......
...@@ -128,7 +128,7 @@ static const int16_t dc_lsp[LPC_ORDER] = { ...@@ -128,7 +128,7 @@ static const int16_t dc_lsp[LPC_ORDER] = {
/** /**
* Cosine table scaled by 2^14 * Cosine table scaled by 2^14
*/ */
static const int16_t cos_tab[COS_TBL_SIZE] = { static const int16_t cos_tab[COS_TBL_SIZE+1] = {
16384, 16383, 16379, 16373, 16364, 16353, 16340, 16324, 16384, 16383, 16379, 16373, 16364, 16353, 16340, 16324,
16305, 16284, 16261, 16235, 16207, 16176, 16143, 16107, 16305, 16284, 16261, 16235, 16207, 16176, 16143, 16107,
16069, 16029, 15986, 15941, 15893, 15843, 15791, 15736, 16069, 16029, 15986, 15941, 15893, 15843, 15791, 15736,
...@@ -193,6 +193,7 @@ static const int16_t cos_tab[COS_TBL_SIZE] = { ...@@ -193,6 +193,7 @@ static const int16_t cos_tab[COS_TBL_SIZE] = {
15679, 15736, 15791, 15843, 15893, 15941, 15986, 16029, 15679, 15736, 15791, 15843, 15893, 15941, 15986, 16029,
16069, 16107, 16143, 16176, 16207, 16235, 16261, 16284, 16069, 16107, 16143, 16176, 16207, 16235, 16261, 16284,
16305, 16324, 16340, 16353, 16364, 16373, 16379, 16383, 16305, 16324, 16340, 16353, 16364, 16373, 16379, 16383,
16384
}; };
/** /**
......
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