summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/msan/msan_interceptors.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/msan/msan_interceptors.cc')
-rw-r--r--compiler-rt/lib/msan/msan_interceptors.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc
index a7fe09b25ff..02b41efdaca 100644
--- a/compiler-rt/lib/msan/msan_interceptors.cc
+++ b/compiler-rt/lib/msan/msan_interceptors.cc
@@ -35,6 +35,7 @@
#include "sanitizer_common/sanitizer_tls_get_addr.h"
#if SANITIZER_NETBSD
+#define fstat __fstat50
#define gettimeofday __gettimeofday50
#define getrusage __getrusage50
#endif
@@ -688,6 +689,19 @@ INTERCEPTOR(int, putenv, char *string) {
return res;
}
+#if SANITIZER_NETBSD
+INTERCEPTOR(int, fstat, int fd, void *buf) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(fstat)(fd, buf);
+ if (!res)
+ __msan_unpoison(buf, __sanitizer::struct_stat_sz);
+ return res;
+}
+#define MSAN_MAYBE_INTERCEPT_FSTAT INTERCEPT_FUNCTION(fstat)
+#else
+#define MSAN_MAYBE_INTERCEPT_FSTAT
+#endif
+
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
INTERCEPTOR(int, __fxstat, int magic, int fd, void *buf) {
ENSURE_MSAN_INITED();
@@ -1633,6 +1647,7 @@ void InitializeInterceptors() {
INTERCEPT_FUNCTION(putenv);
INTERCEPT_FUNCTION(gettimeofday);
MSAN_MAYBE_INTERCEPT_FCVT;
+ MSAN_MAYBE_INTERCEPT_FSTAT;
MSAN_MAYBE_INTERCEPT___FXSTAT;
MSAN_INTERCEPT_FSTATAT;
MSAN_MAYBE_INTERCEPT___FXSTAT64;
OpenPOWER on IntegriCloud