Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <limits> | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace { | |
| 11 | |
| 12 // TODO(jln): list instead the known cases that fail (ASAN etc), so that | |
| 13 // we can positively check that we support the cases we care about. | |
| 14 #if !defined(NO_TCMALLOC) && !defined(ADDRESS_SANITIZER) | |
| 15 #define MAYBE_MemoryAllocationRestrictions AllocationRestrictions | |
| 16 #else | |
| 17 #define MAYBE_MemoryAllocationRestrictions DISABLED_AllocationRestrictions | |
| 18 #endif | |
| 19 | |
| 20 // Check that we can not allocate a continuous space that cannot be indexed | |
| 21 // via an int. This is used to mitigate vulnerabilities in libraries that use | |
| 22 // int instead of size_t. | |
| 23 // See crbug.com/169327. | |
| 24 TEST(SecurityTest, MAYBE_MemoryAllocationRestrictions) { | |
| 25 scoped_ptr<char, base::FreeDeleter> | |
| 26 ptr(static_cast<char*>(malloc((std::numeric_limits<int>::max)()))); | |
|
Chris Evans
2013/01/11 19:51:51
Isn't it jusr std::numeric_limits<int>::max() ?
To
jln (very slow on Chromium)
2013/01/11 20:02:04
That's because of Windows. Windows defines a macro
| |
| 27 ASSERT_TRUE(ptr == NULL); | |
|
Chris Evans
2013/01/11 19:17:28
The behaviour of tcmalloc within Chromium is to ab
jln (very slow on Chromium)
2013/01/11 20:02:04
No, as discussed on the thread (I suspect this com
| |
| 28 // TODO(jln): a lot more tests here. | |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| OLD | NEW |