This is the mail archive of the gcc-patches@gcc.gnu.org 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 v3 2/2] Fixed dirent sanitizer for 32-bit OS X builds


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 --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
index a93d38d..7ffe298 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 && _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..ac61fa5 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 _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;
-- 
2.1.0


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