diff mbox

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

Message ID 1409076692-65815-3-git-send-email-jrtc27@jrtc27.com
State New
Headers show

Commit Message

Jessica Clarke Aug. 26, 2014, 6:11 p.m. UTC
The _DARWIN_FEATURE_64_BIT_INODE macro indicates whether dirent.d_ino is
64-bit or not, which should be sized appropriately, and whether
dirent.d_seekoff should be defined/checked.

libsanitizer/ChangeLog:

    * sanitizer_common/sanitizer_platform_limits_posix.cc: 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
    build.
---
 libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc | 3 ++-
 libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h  | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
index a93d38d..69c84de 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -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);
-#if SANITIZER_MAC
+#if SANITIZER_MAC && defined(_DARWIN_FEATURE_64_BIT_INODE)
+// The 'd_seekoff' field is only present on OS X for 64-bit builds
 CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
 #elif SANITIZER_FREEBSD
 // 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..0523465 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 {
 #endif
 
 #if SANITIZER_MAC
+# if defined(_DARWIN_FEATURE_64_BIT_INODE)
   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
 #elif SANITIZER_FREEBSD
   struct __sanitizer_dirent {
     unsigned int d_fileno;