diff options
author | Kamil Rytarowski <n54@gmx.com> | 2018-02-20 15:53:30 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2018-02-20 15:53:30 +0000 |
commit | 59a9856e06c1f8eb648daa877d3e05d23564dfc5 (patch) | |
tree | ca5de742a36de6580bf00866c0897accee6adf4a | |
parent | 8317565532f7e9dfaa041ed64577e74fa1c68eaa (diff) | |
download | bcm5719-llvm-59a9856e06c1f8eb648daa877d3e05d23564dfc5.tar.gz bcm5719-llvm-59a9856e06c1f8eb648daa877d3e05d23564dfc5.zip |
Add new interceptor: strmode(3)
Summary:
strmode - convert inode status information into a symbolic string
Sponsored by <The NetBSD Foundation>
Reviewers: joerg, vitalybuka
Reviewed By: vitalybuka
Subscribers: kubamracek, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D43485
llvm-svn: 325588
3 files changed, 35 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 45a4b0b4731..82e4d52b6d4 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -6823,6 +6823,19 @@ INTERCEPTOR(char *, fgetln, __sanitizer_FILE *stream, SIZE_T *len) { #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(); @@ -7052,6 +7065,7 @@ static void InitializeCommonInterceptors() { INIT_DEVNAME; INIT_DEVNAME_R; INIT_FGETLN; + INIT_STRMODE; #if SANITIZER_NETBSD COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h index 022dd59ef8b..f081ecd110c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/compiler-rt/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 diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strmode.cc b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strmode.cc new file mode 100644 index 00000000000..b8d7d8ccf5a --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strmode.cc @@ -0,0 +1,20 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t + +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <unistd.h> + +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; +} |