Opened 8 years ago

#11072 new Bugs

[iostreams] mapped_file::size() returns the wrong size on 32-bit windows platforms for files larger than 4gb

Reported by: James Whitworth <fun4jimmy@…> Owned by: Jonathan Turkanis
Milestone: To Be Determined Component: iostreams
Version: Boost 1.57.0 Severity: Problem
Keywords: mapped_file size 32-bit windows Cc:

Description

The signature is size_t mapped_file::size() which is uint32_t for 32-bit builds. This means files larger than 4gb will return an incorrect value.

Looking at the windows implementation source for mapped_file https://github.com/boostorg/iostreams/blob/master/src/mapped_file.cpp around line 220. The size is queried and stored as a local boost::intmax_t but when assigning to size_ it is static_cast to the smaller type.

I think the fix is to change the size member to be always 64-bit but I'm not familiar enough with the rest of the library to know if this would have any knock on effects. I suspect this is also an issue on linux as well but I am unable to easily test that at the moment,

Change History (0)

Note: See TracTickets for help on using tickets.