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

Unified Diff: ipc/ipc_channel_posix.h

Issue 1120343002: Make IPC::Channel buffers stack based and secure against growth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Optimistic! 8 KB will work. Created 5 years, 7 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 | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_posix.h
diff --git a/ipc/ipc_channel_posix.h b/ipc/ipc_channel_posix.h
index a65283d3beace7fafdd02f9c74b9acb68ad84b96..58c5a058734aa122d43282e255ef50c0e42e7e50 100644
--- a/ipc/ipc_channel_posix.h
+++ b/ipc/ipc_channel_posix.h
@@ -174,25 +174,17 @@ class IPC_EXPORT ChannelPosix : public Channel,
// Messages to be sent are queued here.
std::queue<Message*> output_queue_;
- // We assume a worst case: kReadBufferSize bytes of messages, where each
- // message has no payload and a full complement of descriptors.
- static const size_t kMaxReadFDs =
- (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) *
- MessageAttachmentSet::kMaxDescriptorsPerMessage;
-
- // Buffer size for file descriptors used for recvmsg. On Mac the CMSG macros
- // don't seem to be constant so we have to pick a "large enough" value.
-#if defined(OS_MACOSX)
- static const size_t kMaxReadFDBuffer = 1024;
-#else
- static const size_t kMaxReadFDBuffer = CMSG_SPACE(sizeof(int) * kMaxReadFDs);
-#endif
-
- // Temporary buffer used to receive the file descriptors from recvmsg.
- // Code that writes into this should immediately read them out and save
- // them to input_fds_, since this buffer will be re-used anytime we call
- // recvmsg.
- char input_cmsg_buf_[kMaxReadFDBuffer];
+ // Worst case for file descriptors would be : kReadBufferSize bytes
+ // of messages, where each message has no payload and a full
+ // complement of descriptors:
+ // CMSG_SPACE(sizeof(int) *
+ // (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) *
+ // MessageAttachmentSet::kMaxDescriptorsPerMessage)
+ //
+ // If we allocate memory for that in recvmsg we would waste hundreds
+ // of KB. Instead we note that we will only send file descriptors
Mark Seaborn 2015/05/06 17:50:16 This assumption seems rather risky to me, because
+ // occasionally and use a reasonable buffer of 8 KB.
+ static const size_t kMaxReadFDBuffer = 8192;
// File descriptors extracted from messages coming off of the channel. The
// handles may span messages and come off different channels from the message
« no previous file with comments | « no previous file | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698