diff options
author | Kostya Serebryany <kcc@google.com> | 2013-01-25 11:46:22 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-01-25 11:46:22 +0000 |
commit | 65199f1b253c4bfb225805629217acb8f0b1e185 (patch) | |
tree | 1c5ad5bb27171feeae8df5b1126f835f933f208b /lib/asan/asan_allocator.cc | |
parent | 6503100c43c8951f436698b47362cdc8c2ec0a69 (diff) |
[sanitizer] fix calloc overflow in asan/tsan/msan
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@173441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_allocator.cc')
-rw-r--r-- | lib/asan/asan_allocator.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc index 30dd4cedd..370307a89 100644 --- a/lib/asan/asan_allocator.cc +++ b/lib/asan/asan_allocator.cc @@ -35,6 +35,7 @@ #include "asan_thread.h" #include "asan_thread_registry.h" #include "sanitizer/asan_interface.h" +#include "sanitizer_common/sanitizer_allocator.h" #include "sanitizer_common/sanitizer_atomic.h" #include "sanitizer_common/sanitizer_mutex.h" @@ -712,6 +713,7 @@ void *asan_malloc(uptr size, StackTrace *stack) { } void *asan_calloc(uptr nmemb, uptr size, StackTrace *stack) { + if (__sanitizer::CallocShouldReturnNullDueToOverflow(size, nmemb)) return 0; void *ptr = (void*)Allocate(0, nmemb * size, stack, FROM_MALLOC); if (ptr) REAL(memset)(ptr, 0, nmemb * size); |