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

Unified Diff: mojo/system/core.cc

Issue 320263004: Mojo: Remove redundant verification of Options pointers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/core.cc
diff --git a/mojo/system/core.cc b/mojo/system/core.cc
index 8c68dc6eaa88ae9e2ec40737573ae1c4cb84dde8..827d96a327b157168cb7dd0cd7d7defddb435de7 100644
--- a/mojo/system/core.cc
+++ b/mojo/system/core.cc
@@ -293,25 +293,16 @@ MojoResult Core::ReadMessage(MojoHandle message_pipe_handle,
MojoResult Core::CreateDataPipe(const MojoCreateDataPipeOptions* options,
MojoHandle* data_pipe_producer_handle,
MojoHandle* data_pipe_consumer_handle) {
- if (options) {
- // The |struct_size| field must be valid to read.
- if (!VerifyUserPointer<uint32_t>(&options->struct_size))
- return MOJO_RESULT_INVALID_ARGUMENT;
- // And then |options| must point to at least |options->struct_size| bytes.
- if (!VerifyUserPointerWithSize<MOJO_ALIGNOF(int64_t)>(options,
- options->struct_size))
- return MOJO_RESULT_INVALID_ARGUMENT;
- }
- if (!VerifyUserPointer<MojoHandle>(data_pipe_producer_handle))
- return MOJO_RESULT_INVALID_ARGUMENT;
- if (!VerifyUserPointer<MojoHandle>(data_pipe_consumer_handle))
- return MOJO_RESULT_INVALID_ARGUMENT;
-
- MojoCreateDataPipeOptions validated_options = { 0 };
+ MojoCreateDataPipeOptions validated_options = {};
+ // This will verify the |options| pointer.
MojoResult result = DataPipe::ValidateCreateOptions(options,
&validated_options);
if (result != MOJO_RESULT_OK)
return result;
+ if (!VerifyUserPointer<MojoHandle>(data_pipe_producer_handle))
+ return MOJO_RESULT_INVALID_ARGUMENT;
+ if (!VerifyUserPointer<MojoHandle>(data_pipe_consumer_handle))
+ return MOJO_RESULT_INVALID_ARGUMENT;
scoped_refptr<DataPipeProducerDispatcher> producer_dispatcher(
new DataPipeProducerDispatcher());
@@ -414,24 +405,15 @@ MojoResult Core::CreateSharedBuffer(
const MojoCreateSharedBufferOptions* options,
uint64_t num_bytes,
MojoHandle* shared_buffer_handle) {
- if (options) {
- // The |struct_size| field must be valid to read.
- if (!VerifyUserPointer<uint32_t>(&options->struct_size))
- return MOJO_RESULT_INVALID_ARGUMENT;
- // And then |options| must point to at least |options->struct_size| bytes.
- if (!VerifyUserPointerWithSize<MOJO_ALIGNOF(int64_t)>(options,
- options->struct_size))
- return MOJO_RESULT_INVALID_ARGUMENT;
- }
- if (!VerifyUserPointer<MojoHandle>(shared_buffer_handle))
- return MOJO_RESULT_INVALID_ARGUMENT;
-
- MojoCreateSharedBufferOptions validated_options = { 0 };
+ MojoCreateSharedBufferOptions validated_options = {};
+ // This will verify the |options| pointer.
MojoResult result =
SharedBufferDispatcher::ValidateCreateOptions(options,
&validated_options);
if (result != MOJO_RESULT_OK)
return result;
+ if (!VerifyUserPointer<MojoHandle>(shared_buffer_handle))
+ return MOJO_RESULT_INVALID_ARGUMENT;
scoped_refptr<SharedBufferDispatcher> dispatcher;
result = SharedBufferDispatcher::Create(validated_options, num_bytes,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698