[Bug Fix] Fix accessing MBox files > 2 GByte



Hi all,

attached is a patch which fixes accessing MBox files > 2 GByte.  See [1] for a description of the symptoms.  
The patch should be usable for both the Gtk-2 and Gtk-3 branches.

The bug is caused by blindly mixing various integer types with different sizes in the Balsa code, in particular 
int/gint, off_t, ssize_t/size_t and gint64, when using g_mime_stream_* functions.  On a POSIX system, run 'getconf -a | 
grep "_POSIX_V7_.*1$"' to see which definition from [2] applies.

In any case, on POSIX int/gint is *always* 32 bits, which explains the bug.  Otoh, off_t /should/ always be 
64 bits if glibc is used(at least if _FILE_OFFSET_BITS is defined as 64), so it /may/ be mixed with gint64 
(which is *guaranteed* to be 64 bits in any case).  Both size_t and ssize_t will typically be 32 bits on a 32 
bit system, and 64 on a 64 bit system.

On other systems, results may be completely different, as ISO9899 does not define sizes.

I guess there are more "fishy" data type mixtures than the few I found to fix the particular bug.  Maybe time 
to run a good static analyser like FlexeLint against the Balsa code to find these issues (which would be a huge task, 
though)...

Opinions?

Best,
Albrecht.


[1] <https://mail.gnome.org/archives/balsa-list/2016-May/msg00003.html>
[2] <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html>

Attachment: fix-mbox-2gb.diff
Description: Text Data

Attachment: pgpB0wUVwjmbJ.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]