# HG changeset patch # User jbr # Date 1236210910 0 # Node ID c78af85f414dd741d7dfdae9d0acbdce2b2ea343 # Parent 37bb2785a35bfdf18263652dcbc4bfa334b9bc6f 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. diff -r 37bb2785a35b -r c78af85f414d flacdec.c --- 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)) {