changeset 4786:c4e1c57a2b74

7114611: (fs) DirectoryStream fails with SIGBUS on some embedded platforms, dirent alignment Reviewed-by: dholmes, alanb Contributed-by: carlos.lucasius@oracle.com
author alanb
date Wed, 15 Feb 2012 20:56:20 +0000
parents a152fc3c4c32
children a188c3094dba
files src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Wed Feb 15 10:40:30 2012 -0800
+++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Wed Feb 15 20:56:20 2012 +0000
@@ -624,9 +624,12 @@
 
 JNIEXPORT jbyteArray JNICALL
 Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong value) {
-    char entry[sizeof(struct dirent64) + PATH_MAX + 1];
-    struct dirent64* ptr = (struct dirent64*)&entry;
     struct dirent64* result;
+    struct {
+        struct dirent64 buf;
+        char name_extra[PATH_MAX + 1 - sizeof result->d_name];
+    } entry;
+    struct dirent64* ptr = &entry.buf;
     int res;
     DIR* dirp = jlong_to_ptr(value);