diff options
author | lhchavez <lhchavez@chromium.org> | 2016-01-08 16:47:54 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-09 00:49:12 +0000 |
commit | 41bc841af01d297a6d337a62a195cd4080dc7639 (patch) | |
tree | f5723e7e53f58ce707d655329753787d441064dc /mojo/edk/system/data_pipe.cc | |
parent | 7e642027bde0962b5ff5ee85fe6b3cd61fef7fd5 (diff) | |
download | chromium_src-41bc841af01d297a6d337a62a195cd4080dc7639.zip chromium_src-41bc841af01d297a6d337a62a195cd4080dc7639.tar.gz chromium_src-41bc841af01d297a6d337a62a195cd4080dc7639.tar.bz2 |
mojo: Fix the size of several platform-specific structs
Having SerializedPlatformHandleDispatcher::platform_handle_index (and
other platform-specific structs) be a size_t causes 64-bit processes
communicating with 32-bit processes to fail the size check. This change
fixes the size of |platform_handle_index| (and similar ones) so it is
fixed across platforms (to uint32_t) so that the error goes away.
BUG=574945
TEST=32-bit ARC communication works in 64-bit Chrome OS
Review URL: https://codereview.chromium.org/1568693002
Cr-Commit-Position: refs/heads/master@{#368488}
Diffstat (limited to 'mojo/edk/system/data_pipe.cc')
-rw-r--r-- | mojo/edk/system/data_pipe.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/mojo/edk/system/data_pipe.cc b/mojo/edk/system/data_pipe.cc index 3f53798..54a6df4 100644 --- a/mojo/edk/system/data_pipe.cc +++ b/mojo/edk/system/data_pipe.cc @@ -8,6 +8,9 @@ #include <stdint.h> #include <string.h> +#include <algorithm> +#include <limits> + #include "mojo/edk/system/configuration.h" #include "mojo/edk/system/options_validation.h" #include "mojo/edk/system/raw_channel.h" @@ -18,17 +21,17 @@ namespace edk { namespace { -const size_t kInvalidDataPipeHandleIndex = static_cast<size_t>(-1); +const uint32_t kInvalidDataPipeHandleIndex = static_cast<uint32_t>(-1); struct MOJO_ALIGNAS(8) SerializedDataPipeHandleDispatcher { - size_t platform_handle_index; // (Or |kInvalidDataPipeHandleIndex|.) + uint32_t platform_handle_index; // (Or |kInvalidDataPipeHandleIndex|.) // These are from MojoCreateDataPipeOptions MojoCreateDataPipeOptionsFlags flags; uint32_t element_num_bytes; uint32_t capacity_num_bytes; - size_t shared_memory_handle_index; // (Or |kInvalidDataPipeHandleIndex|.) + uint32_t shared_memory_handle_index; // (Or |kInvalidDataPipeHandleIndex|.) uint32_t shared_memory_size; }; @@ -119,7 +122,9 @@ void DataPipe::EndSerialize(const MojoCreateDataPipeOptions& options, SerializedDataPipeHandleDispatcher* serialization = static_cast<SerializedDataPipeHandleDispatcher*>(destination); if (channel_handle.is_valid()) { - serialization->platform_handle_index = platform_handles->size(); + DCHECK(platform_handles->size() < std::numeric_limits<uint32_t>::max()); + serialization->platform_handle_index = + static_cast<uint32_t>(platform_handles->size()); platform_handles->push_back(channel_handle.release()); } else { serialization->platform_handle_index = kInvalidDataPipeHandleIndex; @@ -131,7 +136,9 @@ void DataPipe::EndSerialize(const MojoCreateDataPipeOptions& options, serialization->shared_memory_size = static_cast<uint32_t>(shared_memory_size); if (serialization->shared_memory_size) { - serialization->shared_memory_handle_index = platform_handles->size(); + DCHECK(platform_handles->size() < std::numeric_limits<uint32_t>::max()); + serialization->shared_memory_handle_index = + static_cast<uint32_t>(platform_handles->size()); platform_handles->push_back(shared_memory_handle.release()); } else { serialization->shared_memory_handle_index = kInvalidDataPipeHandleIndex; |