aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/flacdec.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-02-15 09:52:11 -0800
committerReinhard Tartler <siretart@tauware.de>2012-02-26 10:03:14 +0100
commit6dcbbdc0116a50370d66f0f20d74a70d56568382 (patch)
treeb7210f52e47ffc7e7d432645759e2f06bfa830d9 /libavcodec/flacdec.c
parente43bd4fa58b8e72eedad9a1c160b12bf8915d45e (diff)
downloadffmpeg-6dcbbdc0116a50370d66f0f20d74a70d56568382.tar.gz
flac: fix infinite loops on all-zero input or end-of-stream.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 52e4018be47697a60f4f18f83551766df31f5adf) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec/flacdec.c')
-rw-r--r--libavcodec/flacdec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 58eb66def9..440a55d3e9 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -422,7 +422,16 @@ static inline int decode_subframe(FLACContext *s, int channel)
type = get_bits(&s->gb, 6);
if (get_bits1(&s->gb)) {
+ int left = get_bits_left(&s->gb);
wasted = 1;
+ if ( left < 0 ||
+ (left < s->curr_bps && !show_bits_long(&s->gb, left)) ||
+ !show_bits_long(&s->gb, s->curr_bps)) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid number of wasted bits > available bits (%d) - left=%d\n",
+ s->curr_bps, left);
+ return AVERROR_INVALIDDATA;
+ }
while (!get_bits1(&s->gb))
wasted++;
s->curr_bps -= wasted;