aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-08-27 07:19:11 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-08-27 07:19:11 +0000
commit39b434c6ae0ff155d4dd58d4f9bc1d37fff4e129 (patch)
tree942fdd956270f58adcc70bdd3fad8abb1836f1af /libavcodec
parent716d73b47dfce135ce6f177553e4b8e7826e0c55 (diff)
downloadffmpeg-39b434c6ae0ff155d4dd58d4f9bc1d37fff4e129.tar.gz
check the validity of the amount of the remaining bytes in the bitsteam before memcpy
Originally committed as revision 6105 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpegaudiodec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index c76e05bc97..2d669a87eb 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -2522,7 +2522,10 @@ static int mp_decode_frame(MPADecodeContext *s,
align_get_bits(&s->gb);
assert((get_bits_count(&s->gb) & 7) == 0);
s->last_buf_size= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
- memcpy(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), s->last_buf_size);
+ if(s->last_buf_size <0 || s->last_buf_size > BACKSTEP_SIZE || nb_frames<0)
+ s->last_buf_size= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
+ assert(s->last_buf_size <= buf_size - HEADER_SIZE);
+ memcpy(s->last_buf, s->gb.buffer + buf_size - HEADER_SIZE - s->last_buf_size, s->last_buf_size);
break;
}