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/tsan/tests | |
parent | 6503100c43c8951f436698b47362cdc8c2ec0a69 (diff) | |
download | compiler-rt-65199f1b253c4bfb225805629217acb8f0b1e185.tar.gz compiler-rt-65199f1b253c4bfb225805629217acb8f0b1e185.tar.bz2 compiler-rt-65199f1b253c4bfb225805629217acb8f0b1e185.tar.xz |
[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/tsan/tests')
-rw-r--r-- | lib/tsan/tests/unit/tsan_mman_test.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/tsan/tests/unit/tsan_mman_test.cc b/lib/tsan/tests/unit/tsan_mman_test.cc index 988918ff..af813a2c 100644 --- a/lib/tsan/tests/unit/tsan_mman_test.cc +++ b/lib/tsan/tests/unit/tsan_mman_test.cc @@ -10,6 +10,7 @@ // This file is a part of ThreadSanitizer (TSan), a race detector. // //===----------------------------------------------------------------------===// +#include <limits> #include "tsan_mman.h" #include "tsan_rtl.h" #include "gtest/gtest.h" @@ -145,4 +146,13 @@ TEST(Mman, Stats) { EXPECT_EQ(__tsan_get_free_bytes(), free0); EXPECT_EQ(__tsan_get_unmapped_bytes(), unmapped0); } + +TEST(Mman, CallocOverflow) { + size_t kArraySize = 4096; + volatile size_t kMaxSizeT = std::numeric_limits<size_t>::max(); + volatile size_t kArraySize2 = kMaxSizeT / kArraySize + 10; + volatile void *p = calloc(kArraySize, kArraySize2); // Should return 0. + EXPECT_EQ(0L, p); +} + } // namespace __tsan |