[PATCH] D18851: [sanitizer] Add early call handling to strlen interceptor
Derek Bruening via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 17:38:39 PDT 2016
bruening created this revision.
bruening added a reviewer: dim.
bruening added subscribers: samsonov, llvm-commits.
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.
http://reviews.llvm.org/D18851
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -206,6 +206,12 @@
#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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18851.52875.patch
Type: text/x-patch
Size: 746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160407/4201fbf9/attachment.bin>
More information about the llvm-commits
mailing list