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

Side by Side Diff: base/posix/unix_domain_socket_linux.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « base/pickle_unittest.cc ('k') | base/prefs/base_prefs_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/posix/unix_domain_socket_linux.h" 5 #include "base/posix/unix_domain_socket_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 int* wire_fds = NULL; 129 int* wire_fds = NULL;
130 unsigned wire_fds_len = 0; 130 unsigned wire_fds_len = 0;
131 base::ProcessId pid = -1; 131 base::ProcessId pid = -1;
132 132
133 if (msg.msg_controllen > 0) { 133 if (msg.msg_controllen > 0) {
134 struct cmsghdr* cmsg; 134 struct cmsghdr* cmsg;
135 for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { 135 for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
136 const unsigned payload_len = cmsg->cmsg_len - CMSG_LEN(0); 136 const unsigned payload_len = cmsg->cmsg_len - CMSG_LEN(0);
137 if (cmsg->cmsg_level == SOL_SOCKET && 137 if (cmsg->cmsg_level == SOL_SOCKET &&
138 cmsg->cmsg_type == SCM_RIGHTS) { 138 cmsg->cmsg_type == SCM_RIGHTS) {
139 DCHECK(payload_len % sizeof(int) == 0); 139 DCHECK_EQ(payload_len % sizeof(int), 0u);
140 DCHECK(wire_fds == NULL); 140 DCHECK_EQ(wire_fds, static_cast<void*>(nullptr));
141 wire_fds = reinterpret_cast<int*>(CMSG_DATA(cmsg)); 141 wire_fds = reinterpret_cast<int*>(CMSG_DATA(cmsg));
142 wire_fds_len = payload_len / sizeof(int); 142 wire_fds_len = payload_len / sizeof(int);
143 } 143 }
144 #if !defined(OS_NACL_NONSFI) 144 #if !defined(OS_NACL_NONSFI)
145 // The PNaCl toolchain for Non-SFI binary build does not support 145 // The PNaCl toolchain for Non-SFI binary build does not support
146 // SCM_CREDENTIALS. 146 // SCM_CREDENTIALS.
147 if (cmsg->cmsg_level == SOL_SOCKET && 147 if (cmsg->cmsg_level == SOL_SOCKET &&
148 cmsg->cmsg_type == SCM_CREDENTIALS) { 148 cmsg->cmsg_type == SCM_CREDENTIALS) {
149 DCHECK(payload_len == sizeof(struct ucred)); 149 DCHECK_EQ(payload_len, sizeof(struct ucred));
150 DCHECK(pid == -1); 150 DCHECK_EQ(pid, -1);
151 pid = reinterpret_cast<struct ucred*>(CMSG_DATA(cmsg))->pid; 151 pid = reinterpret_cast<struct ucred*>(CMSG_DATA(cmsg))->pid;
152 } 152 }
153 #endif 153 #endif
154 } 154 }
155 } 155 }
156 156
157 if (msg.msg_flags & MSG_TRUNC || msg.msg_flags & MSG_CTRUNC) { 157 if (msg.msg_flags & MSG_TRUNC || msg.msg_flags & MSG_CTRUNC) {
158 for (unsigned i = 0; i < wire_fds_len; ++i) 158 for (unsigned i = 0; i < wire_fds_len; ++i)
159 close(wire_fds[i]); 159 close(wire_fds[i]);
160 errno = EMSGSIZE; 160 errno = EMSGSIZE;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 NOTREACHED(); 232 NOTREACHED();
233 return -1; 233 return -1;
234 } 234 }
235 235
236 if (result_fd) 236 if (result_fd)
237 *result_fd = recv_fds.empty() ? -1 : recv_fds[0]->release(); 237 *result_fd = recv_fds.empty() ? -1 : recv_fds[0]->release();
238 238
239 return reply_len; 239 return reply_len;
240 } 240 }
241 #endif // !defined(OS_NACL_NONSFI) 241 #endif // !defined(OS_NACL_NONSFI)
OLDNEW
« no previous file with comments | « base/pickle_unittest.cc ('k') | base/prefs/base_prefs_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698