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

Side by Side Diff: mojo/public/cpp/bindings/lib/validation_context.cc

Issue 2660733002: Mojo C++ bindings: introduce an optional array to store transferred interface IDs in messages. (Closed)
Patch Set: . Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace internal { 10 namespace internal {
11 11
12 ValidationContext::ValidationContext(const void* data, 12 ValidationContext::ValidationContext(const void* data,
13 size_t data_num_bytes, 13 size_t data_num_bytes,
14 size_t num_handles, 14 size_t num_handles,
15 size_t num_associated_endpoint_handles,
15 Message* message, 16 Message* message,
16 const base::StringPiece& description, 17 const base::StringPiece& description,
17 int stack_depth) 18 int stack_depth)
18 : message_(message), 19 : message_(message),
19 description_(description), 20 description_(description),
20 data_begin_(reinterpret_cast<uintptr_t>(data)), 21 data_begin_(reinterpret_cast<uintptr_t>(data)),
21 data_end_(data_begin_ + data_num_bytes), 22 data_end_(data_begin_ + data_num_bytes),
22 handle_begin_(0), 23 handle_begin_(0),
23 handle_end_(static_cast<uint32_t>(num_handles)), 24 handle_end_(static_cast<uint32_t>(num_handles)),
25 associated_endpoint_handle_begin_(0),
26 associated_endpoint_handle_end_(
27 static_cast<uint32_t>(num_associated_endpoint_handles)),
24 stack_depth_(stack_depth) { 28 stack_depth_(stack_depth) {
29 // Check whether the calculation of |data_end_| or static_cast from size_t to
30 // uint32_t causes overflow.
31 // They shouldn't happen but they do, set the corresponding range to empty.
25 if (data_end_ < data_begin_) { 32 if (data_end_ < data_begin_) {
26 // The calculation of |data_end_| overflowed.
27 // It shouldn't happen but if it does, set the range to empty so
28 // IsValidRange() and ClaimMemory() always fail.
29 NOTREACHED(); 33 NOTREACHED();
30 data_end_ = data_begin_; 34 data_end_ = data_begin_;
31 } 35 }
32 if (handle_end_ < num_handles) { 36 if (handle_end_ < num_handles) {
33 // Assigning |num_handles| to |handle_end_| overflowed.
34 // It shouldn't happen but if it does, set the handle index range to empty.
35 NOTREACHED(); 37 NOTREACHED();
36 handle_end_ = 0; 38 handle_end_ = 0;
37 } 39 }
40 if (associated_endpoint_handle_end_ < num_associated_endpoint_handles) {
41 NOTREACHED();
42 associated_endpoint_handle_end_ = 0;
43 }
38 } 44 }
39 45
40 ValidationContext::~ValidationContext() { 46 ValidationContext::~ValidationContext() {
41 } 47 }
42 48
43 } // namespace internal 49 } // namespace internal
44 } // namespace mojo 50 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_context.h ('k') | mojo/public/cpp/bindings/lib/validation_errors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698