[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 llvm-svn: 267793
This commit is contained in:
parent
af5aebaa32
commit
41939466d1
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue