Index: lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- lib/sanitizer_common/sanitizer_common_interceptors.inc +++ lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -6839,6 +6839,19 @@ #define INIT_FGETLN #endif +#if SANITIZER_INTERCEPT_STRMODE +INTERCEPTOR(void, strmode, u32 mode, char *bp) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, strmode, mode, bp); + REAL(strmode)(mode, bp); + if (bp) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, bp, REAL(strlen)(bp) + 1); +} +#define INIT_STRMODE COMMON_INTERCEPT_FUNCTION(strmode) +#else +#define INIT_STRMODE +#endif + static void InitializeCommonInterceptors() { static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap(); @@ -7068,6 +7081,7 @@ INIT_DEVNAME; INIT_DEVNAME_R; INIT_FGETLN; + INIT_STRMODE; #if SANITIZER_NETBSD COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock); Index: lib/sanitizer_common/sanitizer_platform_interceptors.h =================================================================== --- lib/sanitizer_common/sanitizer_platform_interceptors.h +++ lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -460,5 +460,6 @@ #define SANITIZER_INTERCEPT_DEVNAME SI_NETBSD #define SANITIZER_INTERCEPT_DEVNAME_R SI_NETBSD #define SANITIZER_INTERCEPT_FGETLN SI_NETBSD +#define SANITIZER_INTERCEPT_STRMODE SI_NETBSD #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H Index: test/sanitizer_common/TestCases/NetBSD/strmode.cc =================================================================== --- /dev/null +++ test/sanitizer_common/TestCases/NetBSD/strmode.cc @@ -0,0 +1,20 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t + +#include +#include +#include +#include + +int main(void) { + struct stat st; + char modep[15]; + + if (stat("/etc/hosts", &st)) + exit(1); + + strmode(st.st_mode, modep); + + printf("%s\n", modep); + + return 0; +}