changeset 9133:c78af85f414d libavcodec

flacdec: Add a check for small buffer size. This ensures reading as much of the frame header as possible without excluding the smallest possible FLAC frame. It also fixes a false positive warning message that was being emitted at the end of decoding.
author jbr
date Wed, 04 Mar 2009 23:55:10 +0000
parents 37bb2785a35b
children e82d5e006de5
files flacdec.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flacdec.c	Wed Mar 04 23:24:44 2009 +0000
+++ b/flacdec.c	Wed Mar 04 23:55:10 2009 +0000
@@ -639,6 +639,11 @@
 
     init_get_bits(&s->gb, buf, buf_size*8);
 
+    /* check that there is at least the smallest decodable amount of data.
+       this amount corresponds to the smallest valid FLAC frame possible. */
+    if (buf_size < 24)
+        goto end;
+
     /* check for inline header */
     if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
         if (metadata_parse(s)) {