| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" | 5 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" |
| 6 | 6 |
| 7 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 7 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| 8 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" | 8 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" |
| 9 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 9 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| 10 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 const char* p_obj = reinterpret_cast<const char*>(ptr); | 44 const char* p_obj = reinterpret_cast<const char*>(ptr); |
| 45 const char* p_slot = reinterpret_cast<const char*>(offset); | 45 const char* p_slot = reinterpret_cast<const char*>(offset); |
| 46 MOJO_DCHECK(p_obj > p_slot); | 46 MOJO_DCHECK(p_obj > p_slot); |
| 47 | 47 |
| 48 *offset = static_cast<uint64_t>(p_obj - p_slot); | 48 *offset = static_cast<uint64_t>(p_obj - p_slot); |
| 49 } | 49 } |
| 50 | 50 |
| 51 const void* DecodePointerRaw(const uint64_t* offset) { | 51 const void* DecodePointerRaw(const uint64_t* offset) { |
| 52 if (!*offset) | 52 if (!*offset) |
| 53 return NULL; | 53 return nullptr; |
| 54 return reinterpret_cast<const char*>(offset) + *offset; | 54 return reinterpret_cast<const char*>(offset) + *offset; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool ValidateEncodedPointer(const uint64_t* offset) { | 57 bool ValidateEncodedPointer(const uint64_t* offset) { |
| 58 // Cast to uintptr_t so overflow behavior is well defined. | 58 // Cast to uintptr_t so overflow behavior is well defined. |
| 59 return reinterpret_cast<uintptr_t>(offset) + *offset >= | 59 return reinterpret_cast<uintptr_t>(offset) + *offset >= |
| 60 reinterpret_cast<uintptr_t>(offset); | 60 reinterpret_cast<uintptr_t>(offset); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void EncodeHandle(Handle* handle, std::vector<Handle>* handles) { | 63 void EncodeHandle(Handle* handle, std::vector<Handle>* handles) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (!bounds_checker->ClaimMemory(data, header->num_bytes)) { | 108 if (!bounds_checker->ClaimMemory(data, header->num_bytes)) { |
| 109 ReportValidationError(VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE); | 109 ReportValidationError(VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE); |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace internal | 116 } // namespace internal |
| 117 } // namespace mojo | 117 } // namespace mojo |
| OLD | NEW |