[hwasan] Fix malloc overflow detection.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Fri, 7 Sep 2018 00:27:11 +0000 (00:27 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Fri, 7 Sep 2018 00:27:11 +0000 (00:27 +0000)
commit5b332abd66c3d6e7ef84326989ab17eb99ae24d4
treef054418c7e28dfa5cdabe79d47f972fdd098cb93
parent1fe3e8b26fffe117a66e7accb413da627740abee
[hwasan] Fix malloc overflow detection.

Check size limit before rounding up, otherwise malloc((size_t)-1)
would happily allocate 0 bytes.

Steal a nice test case from scudo.

llvm-svn: 341612
compiler-rt/lib/hwasan/hwasan_allocator.cc
compiler-rt/test/hwasan/TestCases/sizes.cpp [new file with mode: 0644]