[flac-dev] 2GB limit patch

nu774 honeycomb77 at gmail.com
Mon Mar 4 17:57:25 PST 2013


> This is an older issue reported in 2007:
> http://lists.xiph.org/pipermail/flac-dev/2007-September/002423.html
>
> The fix would be to use _ftelli64 instead of ftell with Visual Studio.
> http://msdn.microsoft.com/en-us/library/0ys3hc0b%28v=vs.110%29.aspx

That's not enough. At least, the followings are also needed.

1. Change off_t to something else. off_t can lead to ABI issue when used 
in public API, since it's definition can change even on the same system 
(by setting _FILE_OFFSET_BITS or something), and is always 32bit on 
mingw, mingw-w64 and MSVC.
Since FLAC even takes the trouble of casting seek offset to off_t when 
calling fseeko(), it gets truncated to 32bit on Win32 even if you use 
_fseeki64().
This change results in ABI break, but luckily it seems there's only one 
metadata function that uses off_t in public API.

2. i686-pc-mingw also needs fseeko()/ftello() definitions (only 
fseeko64() and ftello64() available).

3. stat()/fstat() must be also taken care of, when it is used to get 
file size.

4. In some place, size of off_t is checked to see if FLAC binary is 
compiled with large file support. These also need modification.


I have made a fork on https://github.com/nu774/FLAC including these 
patches, but it's not tested enough.
Erik already knows at least off_t issue, and he said he'd like to fix it 
in the future. It needs many lines of change (although it basically is a 
trivial replacement).






More information about the flac-dev mailing list