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

Side by Side Diff: mojo/system/shared_buffer_dispatcher.cc

Issue 304303006: Mojo: Specify/check alignment of pointers more carefully. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix msvs Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/message_pipe_dispatcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/system/shared_buffer_dispatcher.h" 5 #include "mojo/system/shared_buffer_dispatcher.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "mojo/public/c/system/macros.h"
11 #include "mojo/system/constants.h" 12 #include "mojo/system/constants.h"
12 #include "mojo/system/memory.h" 13 #include "mojo/system/memory.h"
13 #include "mojo/system/raw_shared_buffer.h" 14 #include "mojo/system/raw_shared_buffer.h"
14 15
15 namespace mojo { 16 namespace mojo {
16 namespace system { 17 namespace system {
17 18
18 namespace { 19 namespace {
19 20
20 struct SerializedSharedBufferDispatcher { 21 struct SerializedSharedBufferDispatcher {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 shared_buffer.swap(shared_buffer_); 143 shared_buffer.swap(shared_buffer_);
143 return scoped_refptr<Dispatcher>(new SharedBufferDispatcher(shared_buffer)); 144 return scoped_refptr<Dispatcher>(new SharedBufferDispatcher(shared_buffer));
144 } 145 }
145 146
146 MojoResult SharedBufferDispatcher::DuplicateBufferHandleImplNoLock( 147 MojoResult SharedBufferDispatcher::DuplicateBufferHandleImplNoLock(
147 const MojoDuplicateBufferHandleOptions* options, 148 const MojoDuplicateBufferHandleOptions* options,
148 scoped_refptr<Dispatcher>* new_dispatcher) { 149 scoped_refptr<Dispatcher>* new_dispatcher) {
149 lock().AssertAcquired(); 150 lock().AssertAcquired();
150 if (options) { 151 if (options) {
151 // The |struct_size| field must be valid to read. 152 // The |struct_size| field must be valid to read.
152 if (!VerifyUserPointer<uint32_t>(&options->struct_size, 1)) 153 if (!VerifyUserPointer<uint32_t>(&options->struct_size))
153 return MOJO_RESULT_INVALID_ARGUMENT; 154 return MOJO_RESULT_INVALID_ARGUMENT;
154 // And then |options| must point to at least |options->struct_size| bytes. 155 // And then |options| must point to at least |options->struct_size| bytes.
155 if (!VerifyUserPointer<void>(options, options->struct_size)) 156 if (!VerifyUserPointerWithSize<MOJO_ALIGNOF(int64_t)>(options,
157 options->struct_size))
156 return MOJO_RESULT_INVALID_ARGUMENT; 158 return MOJO_RESULT_INVALID_ARGUMENT;
157 159
158 if (options->struct_size < sizeof(*options)) 160 if (options->struct_size < sizeof(*options))
159 return MOJO_RESULT_INVALID_ARGUMENT; 161 return MOJO_RESULT_INVALID_ARGUMENT;
160 // We don't actually do anything with |options|. 162 // We don't actually do anything with |options|.
161 } 163 }
162 164
163 *new_dispatcher = new SharedBufferDispatcher(shared_buffer_); 165 *new_dispatcher = new SharedBufferDispatcher(shared_buffer_);
164 return MOJO_RESULT_OK; 166 return MOJO_RESULT_OK;
165 } 167 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return MOJO_WAIT_FLAG_NONE; 238 return MOJO_WAIT_FLAG_NONE;
237 } 239 }
238 240
239 MojoWaitFlags SharedBufferDispatcher::SatisfiableFlagsNoLock() const { 241 MojoWaitFlags SharedBufferDispatcher::SatisfiableFlagsNoLock() const {
240 // TODO(vtl): Add transferrable flag. 242 // TODO(vtl): Add transferrable flag.
241 return MOJO_WAIT_FLAG_NONE; 243 return MOJO_WAIT_FLAG_NONE;
242 } 244 }
243 245
244 } // namespace system 246 } // namespace system
245 } // namespace mojo 247 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_pipe_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698