[PATCH] [Sanitizers] Intercept opendir()

Viktor Kutuzov vkutuzov at accesssoftek.com
Wed Jan 14 08:18:06 PST 2015


Hi kcc, samsonov, eugenis,

http://reviews.llvm.org/D6968

Files:
  lib/sanitizer_common/sanitizer_common_interceptors.inc

Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -2157,6 +2157,14 @@
 #endif
 
 #if SANITIZER_INTERCEPT_READDIR
+// On FreeBSD opendir() relies on strlen() so we have to intercept it.
+INTERCEPTOR(__sanitizer_dirent *, opendir, const char *filename) {
+  void *ctx;
+  COMMON_INTERCEPTOR_ENTER(ctx, opendir, filename);
+  COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, REAL(strlen)(filename) + 1);
+  return REAL(opendir)(filename);
+}
+
 INTERCEPTOR(__sanitizer_dirent *, readdir, void *dirp) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, readdir, dirp);
@@ -2185,6 +2193,7 @@
 }
 
 #define INIT_READDIR                  \
+  COMMON_INTERCEPT_FUNCTION(opendir); \
   COMMON_INTERCEPT_FUNCTION(readdir); \
   COMMON_INTERCEPT_FUNCTION(readdir_r);
 #else

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6968.18158.patch
Type: text/x-patch
Size: 957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150114/e78b3a08/attachment.bin>


More information about the llvm-commits mailing list