mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-14 00:58:38 +02:00
avcodec/tta: Fix integer overflow in prediction
Fixes: signed integer overflow: -395281576 + -1827578048 cannot be represented in type 'int' Fixes: 16038/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5646109705240576 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 7e9aecc9f358901426c134978e764ee7beac4944) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
c4981bcf07
commit
6d6965b7c4
@ -225,7 +225,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
int cur_chan = 0, framelen = s->frame_length;
|
int cur_chan = 0, framelen = s->frame_length;
|
||||||
int32_t *p;
|
uint32_t *p;
|
||||||
|
|
||||||
if (avctx->err_recognition & AV_EF_CRCCHECK) {
|
if (avctx->err_recognition & AV_EF_CRCCHECK) {
|
||||||
if (buf_size < 4 ||
|
if (buf_size < 4 ||
|
||||||
@ -259,7 +259,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) {
|
for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++) {
|
||||||
int32_t *predictor = &s->ch_ctx[cur_chan].predictor;
|
int32_t *predictor = &s->ch_ctx[cur_chan].predictor;
|
||||||
TTAFilter *filter = &s->ch_ctx[cur_chan].filter;
|
TTAFilter *filter = &s->ch_ctx[cur_chan].filter;
|
||||||
TTARice *rice = &s->ch_ctx[cur_chan].rice;
|
TTARice *rice = &s->ch_ctx[cur_chan].rice;
|
||||||
@ -332,7 +332,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
// decorrelate in case of multiple channels
|
// decorrelate in case of multiple channels
|
||||||
if (s->channels > 1) {
|
if (s->channels > 1) {
|
||||||
int32_t *r = p - 1;
|
int32_t *r = p - 1;
|
||||||
for (*p += *r / 2; r > p - s->channels; r--)
|
for (*p += *r / 2; r > (int32_t*)p - s->channels; r--)
|
||||||
*r = *(r + 1) - *r;
|
*r = *(r + 1) - *r;
|
||||||
}
|
}
|
||||||
cur_chan = 0;
|
cur_chan = 0;
|
||||||
@ -356,13 +356,13 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
switch (s->bps) {
|
switch (s->bps) {
|
||||||
case 1: {
|
case 1: {
|
||||||
uint8_t *samples = (uint8_t *)frame->data[0];
|
uint8_t *samples = (uint8_t *)frame->data[0];
|
||||||
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
|
for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++)
|
||||||
*samples++ = *p + 0x80;
|
*samples++ = *p + 0x80;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
int16_t *samples = (int16_t *)frame->data[0];
|
int16_t *samples = (int16_t *)frame->data[0];
|
||||||
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
|
for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++)
|
||||||
*samples++ = *p;
|
*samples++ = *p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user