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

Unified Diff: mojo/edk/system/channel_posix.cc

Issue 1890043002: [mojo-edk] Support transferring null Mach ports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add header comments. Created 4 years, 8 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 | « mojo/edk/system/channel.cc ('k') | mojo/edk/system/mach_port_relay.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel_posix.cc
diff --git a/mojo/edk/system/channel_posix.cc b/mojo/edk/system/channel_posix.cc
index bc759e0c159f4af0ed1b3f6a89661d8a35e79b95..8dac516bf02d77dab27c5751f70692a365041fa9 100644
--- a/mojo/edk/system/channel_posix.cc
+++ b/mojo/edk/system/channel_posix.cc
@@ -140,20 +140,19 @@ class ChannelPosix : public Channel,
// On OSX, we can have mach ports which are located in the extra header
// section.
using MachPortsEntry = Channel::Message::MachPortsEntry;
- CHECK(extra_header_size >= num_handles * sizeof(MachPortsEntry));
- size_t num_mach_ports = 0;
- const MachPortsEntry* mach_ports =
- reinterpret_cast<const MachPortsEntry*>(extra_header);
- for (size_t i = 0; i < num_handles; i++) {
- if (mach_ports[i].mach_port != MACH_PORT_NULL)
- num_mach_ports++;
- }
+ using MachPortsExtraHeader = Channel::Message::MachPortsExtraHeader;
+ CHECK(extra_header_size >=
+ sizeof(MachPortsExtraHeader) + num_handles * sizeof(MachPortsEntry));
+ const MachPortsExtraHeader* mach_ports_header =
+ reinterpret_cast<const MachPortsExtraHeader*>(extra_header);
+ size_t num_mach_ports = mach_ports_header->num_ports;
CHECK(num_mach_ports <= num_handles);
if (incoming_platform_handles_.size() + num_mach_ports < num_handles)
return nullptr;
ScopedPlatformHandleVectorPtr handles(
new PlatformHandleVector(num_handles));
+ const MachPortsEntry* mach_ports = mach_ports_header->entries;
for (size_t i = 0, mach_port_index = 0; i < num_handles; ++i) {
if (mach_port_index < num_mach_ports &&
mach_ports[mach_port_index].index == i) {
« no previous file with comments | « mojo/edk/system/channel.cc ('k') | mojo/edk/system/mach_port_relay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698