[msvcrt] properly align struct _stati64's st_size

Damjan Jovanovic damjan.jov at gmail.com
Sat Feb 3 04:47:13 CST 2007


In wine's struct _stati64, st_size has an offset of 20 bytes from the
beginning of the struct, unlike mingw's and Window's 24. This breaks
Java 1.4.x pretty badly, it dies on startup complaining about a
truncated class file (#2953). Using #include <pshpack8.h> and #include
<pshpop8.h> around the struct didn't help, so a padding field was used
instead.

Changelog:
* Added padding so that struct _stati64's st_size has an offset of 24
bytes from the beginning of the struct like it should.
* Added a test proving this is the case in Windows.
* Closes #2953 (Java 1.4.x dies running even trivial programs
("Truncated class file")).

Damjan Jovanovic
-------------- next part --------------
--- a/dlls/msvcrt/msvcrt.h	2007-02-02 23:30:50.000000000 +0200
+++ b/dlls/msvcrt/msvcrt.h	2007-02-03 09:20:15.000000000 +0200
@@ -366,6 +366,7 @@
   short          st_uid;
   short          st_gid;
   MSVCRT__dev_t  st_rdev;
+  long           __pad;
   __int64        st_size;
   MSVCRT_time_t  st_atime;
   MSVCRT_time_t  st_mtime;
--- a/dlls/msvcrt/tests/file.c	2007-02-02 23:30:50.000000000 +0200
+++ b/dlls/msvcrt/tests/file.c	2007-02-03 09:24:29.000000000 +0200
@@ -723,6 +723,12 @@
     _unlink( tempfile );
 }
 
+static void test_stat( void )
+{
+    int offset = offsetof(struct _stati64, st_size);
+    ok(offset == 24, "struct _stati64's st_size is misaligned, got %d, expected 24\n", offset);
+}
+
 static void test_fopen_fclose_fcloseall( void )
 {
     char fname1[] = "empty1";
@@ -813,6 +819,7 @@
     test_file_inherit(arg_v[0]);
     test_file_write_read();
     test_chsize();
+    test_stat();
 
     /* testing stream I/O */
     test_fdopen();
--- a/include/msvcrt/sys/stat.h	2006-11-24 18:18:04.000000000 +0200
+++ b/include/msvcrt/sys/stat.h	2007-02-03 09:25:46.000000000 +0200
@@ -99,6 +99,7 @@
   short          st_uid;
   short          st_gid;
   _dev_t st_rdev;
+  long __pad;
   __int64        st_size;
   time_t st_atime;
   time_t st_mtime;
--- a/include/msvcrt/wchar.h	2006-11-24 18:18:04.000000000 +0200
+++ b/include/msvcrt/wchar.h	2007-02-03 09:32:51.000000000 +0200
@@ -181,6 +181,7 @@
   short          st_uid;
   short          st_gid;
   _dev_t st_rdev;
+  long __pad;
   __int64        st_size;
   time_t st_atime;
   time_t st_mtime;


More information about the wine-patches mailing list