Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1869)

Unified Diff: base/security_unittest.cc

Issue 11857007: TCMalloc: restrict maximum size of memory ranges (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698