summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_libc.cc
AgeCommit message (Collapse)Author
2016-07-14[compiler-rt] Add internal wcslen to avoid crashing on windows 64-bitsEtienne Bergeron
Summary: The function wcslen is incorrectly hooked on windows 64-bits. The interception library is not able to hook without breaking the code. The function is too small and the interception must be done with trampoline-hooking which turned out to be incorrect on a small loop (first few instructions have a backedge). Reviewers: rnk Subscribers: wang0109, chrisha, llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D22363 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275488 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01Fix warnings uncovered by building with clang-clReid Kleckner
Move ifdefs to avoid unused static helpers. Move alignment attribute so that it is respected in GCC and MSVC. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@265153 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20[compiler-rt] Add internal implementations for strlcat and strlcpyAnna Zaks
The compiler-rt should make use of strlcpy() rather than strncpy(). Using internal_strncpy() may be fine with appropriate bounds checking or enforcement of nul-termination elsewhere, but it's just good practice these days to avoid using strncpy() in new code. A patch by Jeremy Sequoia! Differential Revision: http://reviews.llvm.org/D14714 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253690 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01[compiler-rt] Fix build by wrapping lines to 80 chars (NFC)Vedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248973 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30[sanitizer_common] Apply modernize-use-nullptr, other minor fixesVedant Kumar
- Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13310 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248964 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-06[compiler-rt] Make MaybeReexec properly process DYLD_INSERT_LIBRARIES when ↵Kuba Brecka
using non-absolute paths MaybeReexec() in asan_mac.cc checks for presence of the ASan dylib in DYLD_INSERT_LIBRARIES, and if it is there, it will process this env. var. and remove the dylib from its value, so that spawned children don't have this variable set. However, the current implementation only works when using a canonical absolute path to the dylib, it fails to remove the dylib for example when using @executable_path. This patch changes the processing of DYLD_INSERT_LIBRARIES to comparing values only based on filenames (ignoring directories). Reviewed at http://reviews.llvm.org/D7160 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228392 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-21[ASan] Get fake stack code working with GCC 4.8.2.Jay Foad
Summary: TestCases/Linux/heavy_uar_test.cc was failing on my PowerPC64 box with GCC 4.8.2, because the compiler recognised a memset-like loop and turned it into a call to memset, which got intercepted by __asan_memset, which got upset because it was being called on an address in high shadow memory. Use break_optimization to stop the compiler from doing this. Reviewers: kcc, samsonov Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6266 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@222572 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13Fix -Wcast-qual warnings in sanitizersAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221936 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04tsan: fix windows buildDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200778 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25[ASan] Follow-up fix: use #if SANITIZER_WINDOWS, not #ifdefTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195625 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25[ASan] Un-break the Windows buildTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195624 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23[sanitizer] use 16-byte aligned bzero in performance critical place (mostly ↵Kostya Serebryany
for lsan) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195549 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03Add internal_strchrnul functionAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189797 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-30Avoid compiler-generated memset by using internal_memset.Will Dietz
Fixes PR17025. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189693 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29Make InternalAlloc/InternalFree in sanitizer runtimes libc-free by switching ↵Alexey Samsonov
to a custom allocator. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182836 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04asan/tsan: fix compilation errors/bugs on Windows where long is 32-bit even ↵Dmitry Vyukov
in 64-bit mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174312 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28[asan] implement more strict checking for memset/etc parameters. Instead of ↵Kostya Serebryany
checking the first and the last byte, we check the entire shadow region. This costs ~10 slowdown for the instrumented functions. Motivated by a nasty memset-buffer-overflow-by-140-bytes in chrome which was reported as a use-after-free or not at all git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171198 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-26Fix a compiler warning in internal_memmove.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166775 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-26Fix the internal_memmove() implementation that used to skip src[0] if dst < src.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166774 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-16[asan] fix lintKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166006 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15Implement internal_memmove.Alexander Potapenko
Use internal_memmove() and internal_memcpy() in the memcpy() and memmove() wrappers when building the dynamic runtime (OS X only), to work around a bug in resolver functions wrapping. See also http://code.google.com/p/address-sanitizer/issues/detail?id=116 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165939 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-21[Sanitizer] implement internal_strcspnAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162272 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20[tsan] a bit more lint and Makefile changes to run tests from sanitizer_commonKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158821 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18[Sanitizer] add internal_strncmp to sanitizer libcAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158658 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15[Sanitizer] move all the rest re-implementations of libc functions from ASan ↵Alexey Samsonov
runtime to common sanitizer runtime git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158519 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15[Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc ↵Alexey Samsonov
implementations of functions. Move strchr to sanitizer_libc. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158517 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-14[Sanitizer] Move internal_memcmp to common sanitizer libcAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158450 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08[Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158202 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-07[Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make ↵Alexey Samsonov
internal allocations from TSan runtime call InternalAlloc from common runtime git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158148 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[Sanitizer] Move more functions/constants to sanitizer_common.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158056 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-05[Sanitizer] rename sanitizer_defs.h to sanitizer_internal_defs.hAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158001 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-05[Sanitizer] add sanitizer_posix.cc. Move more various functions into ↵Alexey Samsonov
sanitizer_libc: sscanf, munmap, memchr git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157994 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04Remove file-type tags in .cc files in tsan/ and sanitizer_common/Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157928 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04[Sanitizer]: move internal_strcmp to sanitizer_commonAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157926 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04[Sanitizer] Move internal_strncpy to sanitizer_libc (and make its behavior ↵Alexey Samsonov
conforming to manual) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157922 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-31[asan,tsan] rename files in sanitizer_common to have a common prefix ↵Kostya Serebryany
(sanitizer_). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157740 91177308-0d34-0410-b5e6-96231b3b80d8