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

Side by Side Diff: base/posix/unix_domain_socket.h

Issue 11108019: linux: Crash browser on too-big messages to zygote. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update CHECKs Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/posix/unix_domain_socket.cc » ('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 #ifndef BASE_POSIX_UNIX_DOMAIN_SOCKET_H_ 5 #ifndef BASE_POSIX_UNIX_DOMAIN_SOCKET_H_
6 #define BASE_POSIX_UNIX_DOMAIN_SOCKET_H_ 6 #define BASE_POSIX_UNIX_DOMAIN_SOCKET_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 13
14 class Pickle; 14 class Pickle;
15 15
16 class BASE_EXPORT UnixDomainSocket { 16 class BASE_EXPORT UnixDomainSocket {
17 public: 17 public:
18 // Maximum number of file descriptors that can be read by RecvMsg().
19 static const size_t kMaxFileDescriptors;
20
18 // Use sendmsg to write the given msg and include a vector of file 21 // Use sendmsg to write the given msg and include a vector of file
19 // descriptors. Returns true if successful. 22 // descriptors. Returns true if successful.
20 static bool SendMsg(int fd, 23 static bool SendMsg(int fd,
21 const void* msg, 24 const void* msg,
22 size_t length, 25 size_t length,
23 const std::vector<int>& fds); 26 const std::vector<int>& fds);
24 27
25 // Use recvmsg to read a message and an array of file descriptors. Returns 28 // Use recvmsg to read a message and an array of file descriptors. Returns
26 // -1 on failure. Note: will read, at most, 16 descriptors. 29 // -1 on failure. Note: will read, at most, |kMaxFileDescriptors| descriptors.
27 static ssize_t RecvMsg(int fd, 30 static ssize_t RecvMsg(int fd,
28 void* msg, 31 void* msg,
29 size_t length, 32 size_t length,
30 std::vector<int>* fds); 33 std::vector<int>* fds);
31 34
32 // Perform a sendmsg/recvmsg pair. 35 // Perform a sendmsg/recvmsg pair.
33 // 1. This process creates a UNIX DGRAM socketpair. 36 // 1. This process creates a UNIX DGRAM socketpair.
34 // 2. This proces writes a request to |fd| with an SCM_RIGHTS control 37 // 2. This proces writes a request to |fd| with an SCM_RIGHTS control
35 // message containing on end of the fresh socket pair. 38 // message containing on end of the fresh socket pair.
36 // 3. This process blocks reading from the other end of the fresh 39 // 3. This process blocks reading from the other end of the fresh
37 // socketpair. 40 // socketpair.
38 // 4. The target process receives the request, processes it and writes the 41 // 4. The target process receives the request, processes it and writes the
39 // reply to the end of the socketpair contained in the request. 42 // reply to the end of the socketpair contained in the request.
40 // 5. This process wakes up and continues. 43 // 5. This process wakes up and continues.
41 // 44 //
42 // fd: descriptor to send the request on 45 // fd: descriptor to send the request on
43 // reply: buffer for the reply 46 // reply: buffer for the reply
44 // reply_len: size of |reply| 47 // reply_len: size of |reply|
45 // result_fd: (may be NULL) the file descriptor returned in the reply 48 // result_fd: (may be NULL) the file descriptor returned in the reply
46 // (if any) 49 // (if any)
47 // request: the bytes to send in the request 50 // request: the bytes to send in the request
48 static ssize_t SendRecvMsg(int fd, 51 static ssize_t SendRecvMsg(int fd,
49 uint8_t* reply, 52 uint8_t* reply,
50 unsigned reply_len, 53 unsigned reply_len,
51 int* result_fd, 54 int* result_fd,
52 const Pickle& request); 55 const Pickle& request);
53 }; 56 };
54 57
55 #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_POSIX_H_ 58 #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_POSIX_H_
OLDNEW
« no previous file with comments | « no previous file | base/posix/unix_domain_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698