[flac-dev] 2GB limit patch

Cristian Rodríguez crrodriguez at opensuse.org
Mon Mar 4 19:27:30 PST 2013


On 03/04/2013 10:57 PM, nu774 wrote:
>> 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).

Nothing against you code, that's ugly ..but as it is a first step it can 
be forgiven :-)

I will just force flac to be built with 64 bit file offsets and just 
reject any caller trying to include/link libflac into a non-lfs program 
like

http://ac-archive.sourceforge.net/largefile/off_t_headers.html

Then we can fix all the internal problems, without the need of 
typedef'ing around ;)







More information about the flac-dev mailing list