[flac-dev] [PATCH] add a check in FLAC__bitwriter_write_raw_uint32()

Erik de Castro Lopo mle+la at mega-nerd.com
Fri Jan 8 16:02:37 PST 2016


lvqcl wrote:

> FLAC__bitwriter_write_raw_uint32() assumes that the unused bits of the
> 'val' argument are equal to zero, and doesn't check it (an assert was
> added recently, but it's disabled in non-debug builds anyway).
> 
> But it makes more difficult to catch metadata length overflow (such as too
> big picture or padding size), so there's a reason to add such check.
> 
> 
> The function FLAC__bitwriter_write_raw_uint32() simply check sthat unused bits are 0
> 
>      if((bits < 32) && (val>>bits != 0))
>          return false;
> 
> and then calls FLAC__bitwriter_write_raw_uint32_nocheck().
> 
> The new function FLAC__bitwriter_write_raw_uint32_nocheck() is
> an old FLAC__bitwriter_write_raw_uint32() that doesn't do this check,
> and all other functions in bitwriter.c call it if they can guarantee
> that all unused bits are 0.

Applied. Thanks.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


More information about the flac-dev mailing list