diff options
author | Derek Bruening <bruening@google.com> | 2016-04-27 21:20:46 +0000 |
---|---|---|
committer | Derek Bruening <bruening@google.com> | 2016-04-27 21:20:46 +0000 |
commit | c97c82cc2895d3ac599c2fe3c09ba3950de33b4f (patch) | |
tree | 9aa62f855df45689eb6d9f5c1938c1c148ffd0bc /lib | |
parent | 327e73030b57359155c84e3be635e4870c674172 (diff) |
[sanitizer] Add early call handling to strchr + strrchr interceptors
Summary:
The strchr and strrchr interceptors are sometimes invoked too early
for their REAL() counterparts to be initialized. We have seen this in
hooks invoked from tcmalloc on the dlsym() used in initializing
interceptors. A special check is added to use internal_ routines for
this situation.
Reviewers: vitalybuka, aizatsky, filcab
Subscribers: filcab, llvm-commits, eugenis, kcc, zhaoqin, aizatsky, kubabrecka
Differential Revision: http://reviews.llvm.org/D19607
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sanitizer_common/sanitizer_common_interceptors.inc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index 2e0c48e8e..85e60caa2 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -401,6 +401,8 @@ INTERCEPTOR(char*, strcasestr, const char *s1, const char *s2) { #if SANITIZER_INTERCEPT_STRCHR INTERCEPTOR(char*, strchr, const char *s, int c) { void *ctx; + if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) + return internal_strchr(s, c); COMMON_INTERCEPTOR_ENTER(ctx, strchr, s, c); char *result = REAL(strchr)(s, c); uptr len = internal_strlen(s); @@ -432,6 +434,8 @@ INTERCEPTOR(char*, strchrnul, const char *s, int c) { #if SANITIZER_INTERCEPT_STRRCHR INTERCEPTOR(char*, strrchr, const char *s, int c) { void *ctx; + if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) + return internal_strrchr(s, c); COMMON_INTERCEPTOR_ENTER(ctx, strrchr, s, c); uptr len = internal_strlen(s); if (common_flags()->intercept_strchr) |