Menu

#362 Assertion failure after partial read

1.3.0
closed-fixed
nobody
libFLAC (59)
5
2015-03-12
2010-03-05
No

When the "read" callback returns less than the requested number of bytes (e.g. always "1"), libFLAC may trigger an assertion failure inside FLAC__bitreader_read_rice_signed_block(), this is bitreader.c:1074 in flac-1.2.1.tar.gz.

Without --enable-debug, this leads to "sync lost" errors.

Problem is that the function miscalculates the number of bits which were already consumed, when only a few bytes (words==0) are available. When the stop bit is not present in these bytes, the code adds "end" to "cbits":

cbits += end;

This however *always* overflows the "cbits" variable if it was non-zero: "end" is the total number of bits available, and "cbits" is the number of those which were already consumed. "cbits+end" is beyond the defined data buffer. What was probably meant was a simple assignment, instead of an addition. Please verify the attached patch; I have just read your code base for the first time, I might be wrong.

Discussion

  • Max Kellermann

    Max Kellermann - 2010-03-05

    Proposed fix

     
  • Florian Beverborg

    Finally, this fixes the stuttering when playing FLACs with MPD via http!

     
  • Erik

    Erik - 2015-03-12

    This patch doesn't apply to the version of FLAC currently in Git and I have every reason to believe its is fixed.

     
  • Erik

    Erik - 2015-03-12
    • status: open --> closed-fixed
    • Group: --> 1.3.0
     

Log in to post a comment.