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