Commit 2a4700a4 authored by Andreas Cadhalpun's avatar Andreas Cadhalpun

wmavoice: limit wmavoice_decode_packet return value to packet size

Claiming to have decoded more bytes than the packet size is wrong.
Reviewed-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
parent 7d0a1975
...@@ -1982,7 +1982,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, ...@@ -1982,7 +1982,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
*got_frame_ptr) { *got_frame_ptr) {
cnt += s->spillover_nbits; cnt += s->spillover_nbits;
s->skip_bits_next = cnt & 7; s->skip_bits_next = cnt & 7;
return cnt >> 3; res = cnt >> 3;
if (res > avpkt->size) {
av_log(ctx, AV_LOG_ERROR,
"Trying to skip %d bytes in packet of size %d\n",
res, avpkt->size);
return AVERROR_INVALIDDATA;
}
return res;
} else } else
skip_bits_long (gb, s->spillover_nbits - cnt + skip_bits_long (gb, s->spillover_nbits - cnt +
get_bits_count(gb)); // resync get_bits_count(gb)); // resync
...@@ -2001,7 +2008,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, ...@@ -2001,7 +2008,14 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
} else if (*got_frame_ptr) { } else if (*got_frame_ptr) {
int cnt = get_bits_count(gb); int cnt = get_bits_count(gb);
s->skip_bits_next = cnt & 7; s->skip_bits_next = cnt & 7;
return cnt >> 3; res = cnt >> 3;
if (res > avpkt->size) {
av_log(ctx, AV_LOG_ERROR,
"Trying to skip %d bytes in packet of size %d\n",
res, avpkt->size);
return AVERROR_INVALIDDATA;
}
return res;
} else if ((s->sframe_cache_size = pos) > 0) { } else if ((s->sframe_cache_size = pos) > 0) {
/* rewind bit reader to start of last (incomplete) superframe... */ /* rewind bit reader to start of last (incomplete) superframe... */
init_get_bits(gb, avpkt->data, size << 3); init_get_bits(gb, avpkt->data, size << 3);
......
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