[PATCH] D126696: sanitizers: Do not include crypt.h if SANITIZER_INTERCEPT_CRYPT_R is undef

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 06:19:00 PDT 2022


thakis created this revision.
thakis added reviewers: eugenis, vitalybuka.
thakis added a project: Sanitizers.
Herald added a subscriber: Enna1.
Herald added a project: All.
thakis requested review of this revision.

sanitizer_intercept_overriders.h might override SANITIZER_INTERCEPT_CRYPT_R to
be undefined. There's no need to require crypt.h in that case.

(The motivation is that crypt() moved from glibc into its own package at around
debian bullseye, which makes intercepting it and building with a single sysroot
that supports both pre-bullseye and post-bullseye a bit hairy.)


https://reviews.llvm.org/D126696

Files:
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h


Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -18,6 +18,7 @@
 
 #include "sanitizer_internal_defs.h"
 #include "sanitizer_platform.h"
+#include "sanitizer_platform_interceptors.h"
 
 #if defined(__sparc__)
 // FIXME: This can't be included from tsan which does not support sparc yet.
@@ -298,9 +299,12 @@
 extern unsigned struct_mq_attr_sz;
 extern unsigned struct_timex_sz;
 extern unsigned struct_statvfs_sz;
-extern unsigned struct_crypt_data_sz;
 #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
 
+#if SANITIZER_INTERCEPT_CRYPT_R
+extern unsigned struct_crypt_data_sz;
+#endif
+
 struct __sanitizer_iovec {
   void *iov_base;
   uptr iov_len;
Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -152,7 +152,6 @@
 #include <linux/serial.h>
 #include <sys/msg.h>
 #include <sys/ipc.h>
-#include <crypt.h>
 #endif  // SANITIZER_ANDROID
 
 #include <link.h>
@@ -174,6 +173,10 @@
 #  include "sanitizer_internal_defs.h"
 #  include "sanitizer_platform_limits_posix.h"
 
+#if SANITIZER_INTERCEPT_CRYPT_R
+#include <crypt.h>
+#endif
+
 namespace __sanitizer {
   unsigned struct_utsname_sz = sizeof(struct utsname);
   unsigned struct_stat_sz = sizeof(struct stat);
@@ -271,9 +274,12 @@
   unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
-  unsigned struct_crypt_data_sz = sizeof(struct crypt_data);
 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
 
+#if SANITIZER_INTERCEPT_CRYPT_R
+  unsigned struct_crypt_data_sz = sizeof(struct crypt_data);
+#endif
+
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
   unsigned struct_timex_sz = sizeof(struct timex);
   unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126696.433065.patch
Type: text/x-patch
Size: 2207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220531/1ecad57b/attachment.bin>


More information about the llvm-commits mailing list