diff options
| author | Viktor Kutuzov <vkutuzov@accesssoftek.com> | 2014-12-22 14:42:24 +0000 |
|---|---|---|
| committer | Viktor Kutuzov <vkutuzov@accesssoftek.com> | 2014-12-22 14:42:24 +0000 |
| commit | 2a5b81dd7f74b44bc543211c92201f3eda4ecb78 (patch) | |
| tree | 8ac6148dd3a61adac774fdf7d542e9b69512c61c /compiler-rt/lib | |
| parent | 949b0d46bfb4e542732ea3bc93e0b4439ef93aa5 (diff) | |
| download | bcm5719-llvm-2a5b81dd7f74b44bc543211c92201f3eda4ecb78.tar.gz bcm5719-llvm-2a5b81dd7f74b44bc543211c92201f3eda4ecb78.zip | |
[Msan] Fix uname() interception on FreeBSD
Differential Revision: http://reviews.llvm.org/D6738
llvm-svn: 224708
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/msan/msan_interceptors.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc index 608fb95bd36..ee3d5f43281 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cc +++ b/compiler-rt/lib/msan/msan_interceptors.cc @@ -849,14 +849,29 @@ INTERCEPTOR(int, getrlimit64, int resource, void *rlim) { #define MSAN_MAYBE_INTERCEPT_GETRLIMIT64 #endif -INTERCEPTOR(int, uname, void *utsname) { +#if SANITIZER_FREEBSD +// FreeBSD's <sys/utsname.h> define uname() as +// static __inline int uname(struct utsname *name) { +// return __xuname(SYS_NMLN, (void*)name); +// } +INTERCEPTOR(int, __xuname, int size, void *utsname) { + ENSURE_MSAN_INITED(); + int res = REAL(__xuname)(size, utsname); + if (!res) + __msan_unpoison(utsname, __sanitizer::struct_utsname_sz); + return res; +} +#define MSAN_INTERCEPT_UNAME INTERCEPT_FUNCTION(__xuname) +#else +INTERCEPTOR(int, uname, struct utsname *utsname) { ENSURE_MSAN_INITED(); int res = REAL(uname)(utsname); - if (!res) { + if (!res) __msan_unpoison(utsname, __sanitizer::struct_utsname_sz); - } return res; } +#define MSAN_INTERCEPT_UNAME INTERCEPT_FUNCTION(uname) +#endif INTERCEPTOR(int, gethostname, char *name, SIZE_T len) { ENSURE_MSAN_INITED(); @@ -1629,7 +1644,7 @@ void InitializeInterceptors() { MSAN_MAYBE_INTERCEPT_FGETS_UNLOCKED; INTERCEPT_FUNCTION(getrlimit); MSAN_MAYBE_INTERCEPT_GETRLIMIT64; - INTERCEPT_FUNCTION(uname); + MSAN_INTERCEPT_UNAME; INTERCEPT_FUNCTION(gethostname); MSAN_MAYBE_INTERCEPT_EPOLL_WAIT; MSAN_MAYBE_INTERCEPT_EPOLL_PWAIT; |

