7114611: (fs) DirectoryStream fails with SIGBUS on some embedded platforms, dirent alignment
authoralanb
Thu, 09 Feb 2012 13:43:15 +0000
changeset 11833 e522d55f4c3d
parent 11832 c0b541c9cc2b
child 11834 0de27a1b7946
7114611: (fs) DirectoryStream fails with SIGBUS on some embedded platforms, dirent alignment Reviewed-by: dholmes, alanb Contributed-by: carlos.lucasius@oracle.com
jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
--- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Wed Feb 08 11:19:25 2012 +0000
+++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Thu Feb 09 13:43:15 2012 +0000
@@ -605,9 +605,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);