| Index: base/security_unittest.cc
|
| diff --git a/base/security_unittest.cc b/base/security_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d226275e06614e10b25b1f74d532d968bc1cc880
|
| --- /dev/null
|
| +++ b/base/security_unittest.cc
|
| @@ -0,0 +1,23 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <limits>
|
| +
|
| +#include "base/version.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace {
|
| +
|
| +// Check that we can not allocate a continuous space that cannot indexed
|
| +// via an int. This is used to mitigate vulnerabilities in libraries that use
|
| +// int instead of size_t.
|
| +TEST(SecurityTest, AllocationRestrictions) {
|
| + scoped_ptr<char, base::FreeDeleter>
|
| + ptr(static_cast<char*>(malloc(std::numeric_limits<int>::max())));
|
| + ASSERT_TRUE(ptr == NULL);
|
| + // TODO(jln): a lot more tests here.
|
| +}
|
| +
|
| +} // namespace
|
|
|