Skip to content

Commit cf16374

Browse files
MaskRaytru
authored andcommitted
[asan] Intercept atoll and strtoll on Windows
`_MSC_VER>=1800` (Visual Studio 2013) supports atoll/strtoll. Remove the obsoleted workaround ASAN_INTERCEPT_ATOLL_AND_STRTOLL. test/asan/TestCases/atoll_strict.c passes but test/asan/TestCases/strtoll_strict.c doesn't. (cherry picked from commit 8033231)
1 parent 4dea033 commit cf16374

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

compiler-rt/lib/asan/asan_interceptors.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ INTERCEPTOR(long, atol, const char *nptr) {
639639
return result;
640640
}
641641

642-
#if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
643642
INTERCEPTOR(long long, strtoll, const char *nptr, char **endptr, int base) {
644643
void *ctx;
645644
ASAN_INTERCEPTOR_ENTER(ctx, strtoll);
@@ -666,7 +665,6 @@ INTERCEPTOR(long long, atoll, const char *nptr) {
666665
ASAN_READ_STRING(ctx, nptr, (real_endptr - nptr) + 1);
667666
return result;
668667
}
669-
#endif // ASAN_INTERCEPT_ATOLL_AND_STRTOLL
670668

671669
#if ASAN_INTERCEPT___CXA_ATEXIT || ASAN_INTERCEPT_ATEXIT
672670
static void AtCxaAtexit(void *unused) {
@@ -751,11 +749,9 @@ void InitializeAsanInterceptors() {
751749

752750
ASAN_INTERCEPT_FUNC(atoi);
753751
ASAN_INTERCEPT_FUNC(atol);
754-
ASAN_INTERCEPT_FUNC(strtol);
755-
#if ASAN_INTERCEPT_ATOLL_AND_STRTOLL
756752
ASAN_INTERCEPT_FUNC(atoll);
753+
ASAN_INTERCEPT_FUNC(strtol);
757754
ASAN_INTERCEPT_FUNC(strtoll);
758-
#endif
759755

760756
// Intecept jump-related functions.
761757
ASAN_INTERCEPT_FUNC(longjmp);

compiler-rt/lib/asan/asan_interceptors.h

-2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ void InitializePlatformInterceptors();
4242
// Use macro to describe if specific function should be
4343
// intercepted on a given platform.
4444
#if !SANITIZER_WINDOWS
45-
# define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 1
4645
# define ASAN_INTERCEPT__LONGJMP 1
4746
# define ASAN_INTERCEPT_INDEX 1
4847
# define ASAN_INTERCEPT_PTHREAD_CREATE 1
4948
#else
50-
# define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 0
5149
# define ASAN_INTERCEPT__LONGJMP 0
5250
# define ASAN_INTERCEPT_INDEX 0
5351
# define ASAN_INTERCEPT_PTHREAD_CREATE 0

compiler-rt/lib/asan/asan_win_dll_thunk.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ INTERCEPT_WRAP_W_W(_expand_dbg)
6565

6666
INTERCEPT_LIBRARY_FUNCTION(atoi);
6767
INTERCEPT_LIBRARY_FUNCTION(atol);
68+
INTERCEPT_LIBRARY_FUNCTION(atoll);
6869
INTERCEPT_LIBRARY_FUNCTION(frexp);
6970
INTERCEPT_LIBRARY_FUNCTION(longjmp);
7071
#if SANITIZER_INTERCEPT_MEMCHR
@@ -91,6 +92,7 @@ INTERCEPT_LIBRARY_FUNCTION(strspn);
9192
INTERCEPT_LIBRARY_FUNCTION(strstr);
9293
INTERCEPT_LIBRARY_FUNCTION(strtok);
9394
INTERCEPT_LIBRARY_FUNCTION(strtol);
95+
INTERCEPT_LIBRARY_FUNCTION(strtoll);
9496
INTERCEPT_LIBRARY_FUNCTION(wcslen);
9597
INTERCEPT_LIBRARY_FUNCTION(wcsnlen);
9698

compiler-rt/test/asan/TestCases/atoll_strict.c

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// RUN: %env_asan_opts=strict_string_checks=false %run %t test3 2>&1
1111
// RUN: %env_asan_opts=strict_string_checks=true not %run %t test3 2>&1 | FileCheck %s --check-prefix=CHECK3
1212

13-
// FIXME: Needs Windows interceptor.
14-
// XFAIL: target={{.*windows-(msvc.*|gnu)}}
15-
1613
#include <assert.h>
1714
#include <stdlib.h>
1815
#include <string.h>

0 commit comments

Comments
 (0)