[compiler-rt] r265705 - [sanitizer] Add early call handling to strlen interceptor
Derek Bruening via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 11:07:09 PDT 2016
Author: bruening
Date: Thu Apr 7 13:07:09 2016
New Revision: 265705
URL: http://llvm.org/viewvc/llvm-project?rev=265705&view=rev
Log:
[sanitizer] Add early call handling to strlen interceptor
Summary:
The strlen interceptor is sometimes invoked too early for REAL(strlen) to
be initialized. A special check is added to use internal_strlen for this
situation.
Reviewers: dim
Subscribers: llvm-commits, samsonov
Differential Revision: http://reviews.llvm.org/D18851
Change-Id: I3acc58f4abbae1904f25324abd84efea67aad0a2
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=265705&r1=265704&r2=265705&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Apr 7 13:07:09 2016
@@ -206,6 +206,12 @@ UNUSED static void DeleteInterceptorMeta
#if SANITIZER_INTERCEPT_STRLEN
INTERCEPTOR(SIZE_T, strlen, const char *s) {
+ // Sometimes strlen is called prior to InitializeCommonInterceptors,
+ // in which case the REAL(strlen) typically used in
+ // COMMON_INTERCEPTOR_ENTER will fail. We use internal_strlen here
+ // to handle that.
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_strlen(s);
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, strlen, s);
SIZE_T result = REAL(strlen)(s);
More information about the llvm-commits
mailing list