| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/validation_context.h" | 5 #include "mojo/public/cpp/bindings/lib/validation_context.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "mojo/public/cpp/bindings/lib/serialization_util.h" | 11 #include "mojo/public/cpp/bindings/lib/serialization_util.h" |
| 12 #include "mojo/public/cpp/bindings/message.h" | 12 #include "mojo/public/cpp/bindings/message.h" |
| 13 #include "mojo/public/cpp/system/handle.h" | 13 #include "mojo/public/cpp/system/handle.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 ValidationContext::ValidationContext(const void* data, | 18 ValidationContext::ValidationContext(const void* data, |
| 19 uint32_t data_num_bytes, | 19 size_t data_num_bytes, |
| 20 size_t num_handles, | 20 size_t num_handles, |
| 21 Message* message, | 21 Message* message, |
| 22 const base::StringPiece& description) | 22 const base::StringPiece& description) |
| 23 : message_(message), | 23 : message_(message), |
| 24 description_(description), | 24 description_(description), |
| 25 data_begin_(reinterpret_cast<uintptr_t>(data)), | 25 data_begin_(reinterpret_cast<uintptr_t>(data)), |
| 26 data_end_(data_begin_ + data_num_bytes), | 26 data_end_(data_begin_ + data_num_bytes), |
| 27 handle_begin_(0), | 27 handle_begin_(0), |
| 28 handle_end_(static_cast<uint32_t>(num_handles)) { | 28 handle_end_(static_cast<uint32_t>(num_handles)) { |
| 29 if (data_end_ < data_begin_) { | 29 if (data_end_ < data_begin_) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return InternalIsValidRange(begin, end); | 77 return InternalIsValidRange(begin, end); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool ValidationContext::InternalIsValidRange(uintptr_t begin, | 80 bool ValidationContext::InternalIsValidRange(uintptr_t begin, |
| 81 uintptr_t end) const { | 81 uintptr_t end) const { |
| 82 return end > begin && begin >= data_begin_ && end <= data_end_; | 82 return end > begin && begin >= data_begin_ && end <= data_end_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace internal | 85 } // namespace internal |
| 86 } // namespace mojo | 86 } // namespace mojo |
| OLD | NEW |