[llvm-commits] [compiler-rt] r173249 - in /compiler-rt/trunk/lib/msan: msan_interceptors.cc tests/msan_test.cc
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Jan 23 02:43:38 PST 2013
Author: eugenis
Date: Wed Jan 23 04:43:38 2013
New Revision: 173249
URL: http://llvm.org/viewvc/llvm-project?rev=173249&view=rev
Log:
[msan] gethostbyname interceptor.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=173249&r1=173248&r2=173249&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Wed Jan 23 04:43:38 2013
@@ -612,6 +612,18 @@
return res;
}
+INTERCEPTOR(int, gethostname, char *name, SIZE_T len) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(gethostname)(name, len);
+ if (!res) {
+ SIZE_T real_len = REAL(strnlen)(name, len);
+ if (real_len < len)
+ ++real_len;
+ __msan_unpoison(name, real_len);
+ }
+ return res;
+}
+
INTERCEPTOR(int, epoll_wait, int epfd, void *events, int maxevents,
int timeout) {
ENSURE_MSAN_INITED();
@@ -936,6 +948,7 @@
INTERCEPT_FUNCTION(statfs64);
INTERCEPT_FUNCTION(fstatfs64);
INTERCEPT_FUNCTION(uname);
+ INTERCEPT_FUNCTION(gethostname);
INTERCEPT_FUNCTION(epoll_wait);
INTERCEPT_FUNCTION(epoll_pwait);
INTERCEPT_FUNCTION(recv);
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=173249&r1=173248&r2=173249&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Wed Jan 23 04:43:38 2013
@@ -1306,6 +1306,13 @@
EXPECT_NOT_POISONED(strlen(u.machine));
}
+TEST(MemorySanitizer, gethostname) {
+ char buf[100];
+ int res = gethostname(buf, 100);
+ assert(!res);
+ EXPECT_NOT_POISONED(strlen(buf));
+}
+
template<class T>
static bool applySlt(T value, T shadow) {
__msan_partial_poison(&value, &shadow, sizeof(T));
More information about the llvm-commits
mailing list