gstdio: use _stat64 for GStatBuf on 64bit mingw. Fixes #1476

The size of stat depends on various macros on Windows which leads to
the problem of size mismatches when glib is built with a different configuration
than a program using it.

For example the autotools build defaults to _FILE_OFFSET_BITS=64 and a program
not defining  _FILE_OFFSET_BITS will allocate a too small struct on the stack,
leading to stack corruption when glib writes to it.

To make the size the user sees always match the default mingw build define GStatBuf
as _stat64 (same as _FILE_OFFSET_BITS=64) under mingw+64bit.
This commit is contained in:
Christoph Reiter
2018-08-05 11:21:26 +02:00
parent 3736139358
commit 63d3311c26
2 changed files with 13 additions and 0 deletions

View File

@@ -44,6 +44,10 @@ G_BEGIN_DECLS
typedef struct _stat32 GStatBuf;
#elif defined(__MINGW64_VERSION_MAJOR) && defined(_WIN64)
typedef struct _stat64 GStatBuf;
#else
typedef struct stat GStatBuf;