[PATCH] D43485: Add new interceptor: strmode(3)
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 19 14:51:22 PST 2018
krytarowski created this revision.
krytarowski added reviewers: joerg, vitalybuka.
krytarowski added a project: Sanitizers.
Herald added a subscriber: kubamracek.
strmode - convert inode status information into a symbolic string
Sponsored by <The NetBSD Foundation>
Repository:
rL LLVM
https://reviews.llvm.org/D43485
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
lib/sanitizer_common/sanitizer_platform_interceptors.h
test/sanitizer_common/TestCases/NetBSD/strmode.cc
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 <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;
+}
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: 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43485.134975.patch
Type: text/x-patch
Size: 2055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180219/c3cb167f/attachment.bin>
More information about the llvm-commits
mailing list