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

Unified Diff: mojo/public/cpp/bindings/lib/validation_util.cc

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_util.h ('k') | mojo/public/cpp/bindings/map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/validation_util.cc
diff --git a/mojo/public/cpp/bindings/lib/validation_util.cc b/mojo/public/cpp/bindings/lib/validation_util.cc
deleted file mode 100644
index cf9db5ba189e58e1bf40bd305a011f3153dfca08..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/bindings/lib/validation_util.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2015 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 "mojo/public/cpp/bindings/lib/validation_util.h"
-
-#include <limits>
-#include <string>
-
-#include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
-#include "mojo/public/cpp/bindings/lib/validation_errors.h"
-
-namespace mojo {
-namespace internal {
-
-bool ValidateEncodedPointer(const uint64_t* offset) {
- // - Make sure |*offset| is no more than 32-bits.
- // - Cast |offset| to uintptr_t so overflow behavior is well defined across
- // 32-bit and 64-bit systems.
- return *offset <= std::numeric_limits<uint32_t>::max() &&
- (reinterpret_cast<uintptr_t>(offset) +
- static_cast<uint32_t>(*offset) >=
- reinterpret_cast<uintptr_t>(offset));
-}
-
-ValidationError ValidateStructHeaderAndClaimMemory(
- const void* data,
- BoundsChecker* bounds_checker,
- std::string* err) {
- if (!IsAligned(data)) {
- MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "";
- return ValidationError::MISALIGNED_OBJECT;
- }
- if (!bounds_checker->IsValidRange(data, sizeof(StructHeader))) {
- MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "";
- return ValidationError::ILLEGAL_MEMORY_RANGE;
- }
-
- const StructHeader* header = static_cast<const StructHeader*>(data);
-
- if (header->num_bytes < sizeof(StructHeader)) {
- MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "";
- return ValidationError::UNEXPECTED_STRUCT_HEADER;
- }
-
- if (!bounds_checker->ClaimMemory(data, header->num_bytes)) {
- MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "";
- return ValidationError::ILLEGAL_MEMORY_RANGE;
- }
-
- return ValidationError::NONE;
-}
-
-} // namespace internal
-} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_util.h ('k') | mojo/public/cpp/bindings/map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698