From 876379e4c2d7bf44a78dc3e596e1f5e80971fd2e Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Wed, 23 Mar 2016 21:24:28 +0000 Subject: [sanitizer] Add strnlen to the common interceptors Summary: Adds strnlen to the common interceptors, under the existing flag intercept_strlen. Removes the now-duplicate strnlen interceptor from asan and msan. This adds strnlen to tsan, which previously did not intercept it. Adds a new test of strnlen to the sanitizer_common test cases. Reviewers: samsonov Subscribers: zhaoqin, llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D18397 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264195 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/msan/msan_interceptors.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'lib/msan/msan_interceptors.cc') diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc index 1b97cb117..c961fdf45 100644 --- a/lib/msan/msan_interceptors.cc +++ b/lib/msan/msan_interceptors.cc @@ -44,6 +44,7 @@ using __sanitizer::atomic_store; using __sanitizer::atomic_uintptr_t; DECLARE_REAL(SIZE_T, strlen, const char *s) +DECLARE_REAL(SIZE_T, strnlen, const char *s, SIZE_T maxlen) #if SANITIZER_FREEBSD #define __errno_location __error @@ -282,14 +283,6 @@ INTERCEPTOR(void, malloc_stats, void) { #define MSAN_MAYBE_INTERCEPT_MALLOC_STATS #endif -INTERCEPTOR(SIZE_T, strnlen, const char *s, SIZE_T n) { - ENSURE_MSAN_INITED(); - SIZE_T res = REAL(strnlen)(s, n); - SIZE_T scan_size = (res == n) ? res : res + 1; - CHECK_UNPOISONED(s, scan_size); - return res; -} - INTERCEPTOR(char *, strcpy, char *dest, const char *src) { // NOLINT ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; @@ -1555,7 +1548,6 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(strndup); MSAN_MAYBE_INTERCEPT___STRNDUP; INTERCEPT_FUNCTION(strncpy); // NOLINT - INTERCEPT_FUNCTION(strnlen); INTERCEPT_FUNCTION(gcvt); INTERCEPT_FUNCTION(strcat); // NOLINT INTERCEPT_FUNCTION(strncat); // NOLINT -- cgit v1.2.3