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

Unified Diff: ipc/ipc_channel_posix.cc

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
« ipc/ipc_channel_posix.h ('K') | « ipc/ipc_channel_posix.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_posix.cc
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc
index aac7e795257a4f0933e3ede563b5b989eedd01cd..6d8fdec70bef757e289a437f6b997c18d1be2f70 100644
--- a/ipc/ipc_channel_posix.cc
+++ b/ipc/ipc_channel_posix.cc
@@ -192,7 +192,6 @@ ChannelPosix::ChannelPosix(const IPC::ChannelHandle& channel_handle,
pipe_name_(channel_handle.name),
in_dtor_(false),
must_unlink_(false) {
- memset(input_cmsg_buf_, 0, sizeof(input_cmsg_buf_));
if (!CreatePipe(channel_handle)) {
// The pipe may have been closed already.
const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client";
@@ -824,7 +823,8 @@ ChannelPosix::ReadState ChannelPosix::ReadData(
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = input_cmsg_buf_;
+ char input_cmsg_buf[kMaxReadFDBuffer];
+ msg.msg_control = input_cmsg_buf;
// recvmsg() returns 0 if the connection has closed or EAGAIN if no data
// is waiting on the pipe.
@@ -835,7 +835,7 @@ ChannelPosix::ReadState ChannelPosix::ReadData(
} else
#endif // IPC_USES_READWRITE
{
- msg.msg_controllen = sizeof(input_cmsg_buf_);
+ msg.msg_controllen = sizeof(input_cmsg_buf);
*bytes_read = HANDLE_EINTR(recvmsg(pipe_.get(), &msg, MSG_DONTWAIT));
}
if (*bytes_read < 0) {
@@ -876,8 +876,9 @@ bool ChannelPosix::ReadFileDescriptorsFromFDPipe() {
struct msghdr msg = { 0 };
msg.msg_iov = &fd_pipe_iov;
msg.msg_iovlen = 1;
- msg.msg_control = input_cmsg_buf_;
- msg.msg_controllen = sizeof(input_cmsg_buf_);
+ char input_cmsg_buf[kMaxReadFDBuffer];
+ msg.msg_control = input_cmsg_buf;
+ msg.msg_controllen = sizeof(input_cmsg_buf);
ssize_t bytes_received =
HANDLE_EINTR(recvmsg(fd_pipe_.get(), &msg, MSG_DONTWAIT));
« ipc/ipc_channel_posix.h ('K') | « ipc/ipc_channel_posix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698