This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] Fixed dirent sanitizer for 32-bit OS X builds

The __DARWIN_64_BIT_INO_T macro is used to indicate whether dirent.d_ino
is 64-bit or not, and so should be sized appropriately. Additionally,
dirent.d_seekoff should only be defined/checked when
__DARWIN_64_BIT_INO_T is defined.


    * sanitizer_common/ Only check
    dirent.d_seekoff on OS X when performing a 64-bit build.
    * sanitizer_common/sanitizer_platform_limits_posix.h: Only define
    dirent.d_seekoff on OS X when performing a 64-bit build, and make
    dirent.d_ino the correct size (32-bit) when performing a 32-bit
 libsanitizer/sanitizer_common/ | 3 ++-
 libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h  | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libsanitizer/sanitizer_common/ b/libsanitizer/sanitizer_common/
index a93d38d..0d1870b 100644
--- a/libsanitizer/sanitizer_common/
+++ b/libsanitizer/sanitizer_common/
@@ -940,7 +940,8 @@ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
 COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
 CHECK_SIZE_AND_OFFSET(dirent, d_ino);
+// The 'd_seekoff' field is only present on OS X for 64-bit builds
 CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
 // There is no 'd_off' field on FreeBSD.
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
index dece2d3..73a4c3f 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -392,12 +392,21 @@ namespace __sanitizer {
+# if __DARWIN_64_BIT_INO_T
   struct __sanitizer_dirent {
     unsigned long long d_ino;
     unsigned long long d_seekoff;
     unsigned short d_reclen;
     // more fields that we don't care about
+# else
+  struct __sanitizer_dirent {
+    unsigned int d_ino;
+    // No d_seekoff for 32-bit
+    unsigned short d_reclen;
+    // more fields that we don't care about
+  };
+# endif
   struct __sanitizer_dirent {
     unsigned int d_fileno;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]