diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 04:05:28 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 04:05:28 +0000 |
commit | 7135bb043af7f66b5ed36e71775e9d1835da7420 (patch) | |
tree | 41c3ee7d52df762392ee36fd03cea80761b03015 /chrome/common/ipc_channel_posix.cc | |
parent | e707d5e60b2191d3ffde90edcbafc01d8d7f7590 (diff) | |
download | chromium_src-7135bb043af7f66b5ed36e71775e9d1835da7420.zip chromium_src-7135bb043af7f66b5ed36e71775e9d1835da7420.tar.gz chromium_src-7135bb043af7f66b5ed36e71775e9d1835da7420.tar.bz2 |
POSIX: Clean up DescriptorSet
In general, the IPC Message objects are const and the iterator state is a void*
kept by the code which is doing the deserialisation.
However, now that we have an array of file descriptors, the index of the next
file descriptor is part of the iteration state and is kept /inside/ the Message
(in the DescriptorSet). This means that it's a mutable member, which is never
too nice and also, since the logging functions want to parse a message multiple
times, we've had to turn off returning an error when one runs off the end of
the array.
Also, the Message copy constructor and assignment function alters the /source/
Message, by stealing all of its descriptors
This patch encodes the index of each file descriptor on the wire. So the state
is moved from inside the DescriptorSet into the serialised data.
Additionally, the DescriptorSet is made into a lazyily created scoped_refptr,
solving the problems with copying messages.
Review URL: http://codereview.chromium.org/20275
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_channel_posix.cc')
-rw-r--r-- | chrome/common/ipc_channel_posix.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc index b46024c..72d1554 100644 --- a/chrome/common/ipc_channel_posix.cc +++ b/chrome/common/ipc_channel_posix.cc @@ -483,13 +483,24 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() { const char* message_tail = Message::FindNext(p, end); if (message_tail) { int len = static_cast<int>(message_tail - p); - const Message m(p, len); + Message m(p, len); if (m.header()->num_fds) { // the message has file descriptors + const char* error = NULL; if (m.header()->num_fds > num_fds - fds_i) { // the message has been completely received, but we didn't get // enough file descriptors. - LOG(WARNING) << "Message needs unreceived descriptors" + error = "Message needs unreceived descriptors"; + } + + if (m.header()->num_fds > + DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE) { + // There are too many descriptors in this message + error = "Message requires an excessive number of descriptors"; + } + + if (error) { + LOG(WARNING) << error << " channel:" << this << " message-type:" << m.type() << " header()->num_fds:" << m.header()->num_fds @@ -499,6 +510,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() { for (unsigned i = fds_i; i < num_fds; ++i) close(fds[i]); input_overflow_fds_.clear(); + // abort the connection return false; } |