diff options
author | Reid Kleckner <rnk@google.com> | 2016-03-22 00:52:47 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-03-22 00:52:47 +0000 |
commit | 71e5da65ab377ff18f49b5480fc982bedb700c48 (patch) | |
tree | 0c731576f39504b7bc39765377e406272bc99281 /lib | |
parent | dfde1951fa9f3f171e0b48fab96372819f9a094a (diff) |
[asan] Intercept strdup on Windows
Some unit tests were failing because we didn't intercept strdup. It
turns out it works just fine on 2013 and 2015 with a small patch to the
interception logic.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264013 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asan/asan_interceptors.cc | 4 | ||||
-rw-r--r-- | lib/asan/asan_interceptors.h | 2 | ||||
-rw-r--r-- | lib/asan/asan_win_dll_thunk.cc | 1 | ||||
-rw-r--r-- | lib/interception/interception_win.cc | 5 |
4 files changed, 5 insertions, 7 deletions
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc index df3d0ed62..914206a22 100644 --- a/lib/asan/asan_interceptors.cc +++ b/lib/asan/asan_interceptors.cc @@ -544,7 +544,6 @@ INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT return REAL(strcpy)(to, from); // NOLINT } -#if ASAN_INTERCEPT_STRDUP INTERCEPTOR(char*, strdup, const char *s) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, strdup); @@ -559,7 +558,6 @@ INTERCEPTOR(char*, strdup, const char *s) { REAL(memcpy)(new_mem, s, length + 1); return reinterpret_cast<char*>(new_mem); } -#endif INTERCEPTOR(SIZE_T, wcslen, const wchar_t *s) { void *ctx; @@ -729,9 +727,7 @@ void InitializeAsanInterceptors() { ASAN_INTERCEPT_FUNC(wcslen); ASAN_INTERCEPT_FUNC(strncat); ASAN_INTERCEPT_FUNC(strncpy); -#if ASAN_INTERCEPT_STRDUP ASAN_INTERCEPT_FUNC(strdup); -#endif #if ASAN_INTERCEPT_STRNLEN ASAN_INTERCEPT_FUNC(strnlen); #endif diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index 279c5f384..a09fcf3b8 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -23,14 +23,12 @@ #if !SANITIZER_WINDOWS # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 1 # define ASAN_INTERCEPT__LONGJMP 1 -# define ASAN_INTERCEPT_STRDUP 1 # define ASAN_INTERCEPT_INDEX 1 # define ASAN_INTERCEPT_PTHREAD_CREATE 1 # define ASAN_INTERCEPT_FORK 1 #else # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 0 # define ASAN_INTERCEPT__LONGJMP 0 -# define ASAN_INTERCEPT_STRDUP 0 # define ASAN_INTERCEPT_INDEX 0 # define ASAN_INTERCEPT_PTHREAD_CREATE 0 # define ASAN_INTERCEPT_FORK 0 diff --git a/lib/asan/asan_win_dll_thunk.cc b/lib/asan/asan_win_dll_thunk.cc index 6d25425ed..b19e22889 100644 --- a/lib/asan/asan_win_dll_thunk.cc +++ b/lib/asan/asan_win_dll_thunk.cc @@ -396,6 +396,7 @@ INTERCEPT_LIBRARY_FUNCTION(strchr); INTERCEPT_LIBRARY_FUNCTION(strcmp); INTERCEPT_LIBRARY_FUNCTION(strcpy); // NOLINT INTERCEPT_LIBRARY_FUNCTION(strcspn); +INTERCEPT_LIBRARY_FUNCTION(strdup); INTERCEPT_LIBRARY_FUNCTION(strlen); INTERCEPT_LIBRARY_FUNCTION(strncat); INTERCEPT_LIBRARY_FUNCTION(strncmp); diff --git a/lib/interception/interception_win.cc b/lib/interception/interception_win.cc index fdecff26a..bd435f16e 100644 --- a/lib/interception/interception_win.cc +++ b/lib/interception/interception_win.cc @@ -108,6 +108,9 @@ static size_t RoundUpToInstrBoundary(size_t size, char *code) { case 0x3D83: // 83 3D XX YY ZZ WW TT = cmp TT, WWZZYYXX cursor += 7; continue; + case 0x7D83: // 83 7D XX YY = cmp dword ptr [ebp+XXh], YY + cursor += 4; + continue; } switch (0x00FFFFFF & *(unsigned int*)(code + cursor)) { case 0x24448A: // 8A 44 24 XX = mov eal, dword ptr [esp+XXh] @@ -120,7 +123,7 @@ static size_t RoundUpToInstrBoundary(size_t size, char *code) { continue; } switch (*(unsigned int *)(code + cursor)) { - case 0X2444B60F: // 0F B6 44 24 XX = movzx eax, byte ptr [esp+XXh] + case 0x2444B60F: // 0F B6 44 24 XX = movzx eax, byte ptr [esp+XXh] cursor += 5; continue; } |