Commit e938637b authored by Kostya Shishkov's avatar Kostya Shishkov

Add checks on input/output buffers size for some audio decoders

Originally committed as revision 10485 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent bf4a1f17
......@@ -590,6 +590,10 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
stereo = get_bits1(&gb);
bits = get_bits1(&gb);
if ((unp_size << !bits) > *data_size) {
av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
return -1;
}
memset(vlc, 0, sizeof(VLC) * 4);
memset(h, 0, sizeof(HuffContext) * 4);
......
......@@ -333,15 +333,17 @@ static int truespeech_decode_frame(AVCodecContext *avctx,
{
TSContext *c = avctx->priv_data;
int i;
int i, j;
short *samples = data;
int consumed = 0;
int16_t out_buf[240];
int iterations;
if (!buf_size)
return 0;
while (consumed < buf_size) {
iterations = FFMIN(buf_size / 32, *data_size / 480);
for(j = 0; j < iterations; j++) {
truespeech_read_frame(c, buf + consumed);
consumed += 32;
......@@ -366,7 +368,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx,
*data_size = consumed * 15;
return buf_size;
return consumed;
}
AVCodec truespeech_decoder = {
......
......@@ -62,6 +62,14 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
in_size = AV_RL16(&buf[2]);
buf += 4;
if (out_size > *data_size) {
av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
return -1;
}
if (in_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");
return -1;
}
if (in_size == out_size) {
for (i = 0; i < out_size; i++)
*samples++ = (*buf++ - 0x80) << 8;
......
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