| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_sandbox_host_linux.h" | 5 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #include <sys/uio.h> | 9 #include <sys/uio.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 // --------------------------------------------------------------------------- | 98 // --------------------------------------------------------------------------- |
| 99 // Requests from the renderer... | 99 // Requests from the renderer... |
| 100 | 100 |
| 101 void HandleRequestFromRenderer(int fd) { | 101 void HandleRequestFromRenderer(int fd) { |
| 102 std::vector<int> fds; | 102 std::vector<int> fds; |
| 103 static const unsigned kMaxMessageLength = 2048; | 103 |
| 104 char buf[kMaxMessageLength]; | 104 // A FontConfigIPC::METHOD_MATCH message could be kMaxFontFamilyLength |
| 105 // bytes long (this is the largest message type). |
| 106 // 128 bytes padding are necessary so recvmsg() does not return MSG_TRUNC |
| 107 // error for a maximum length message. |
| 108 char buf[FontConfigInterface::kMaxFontFamilyLength + 128]; |
| 109 |
| 105 const ssize_t len = base::RecvMsg(fd, buf, sizeof(buf), &fds); | 110 const ssize_t len = base::RecvMsg(fd, buf, sizeof(buf), &fds); |
| 106 if (len == -1) | 111 if (len == -1) { |
| 112 // TODO: should send an error reply, or the sender might block forever. |
| 113 NOTREACHED() |
| 114 << "Sandbox host message is larger than kMaxFontFamilyLength"; |
| 107 return; | 115 return; |
| 116 } |
| 108 if (fds.size() == 0) | 117 if (fds.size() == 0) |
| 109 return; | 118 return; |
| 110 | 119 |
| 111 Pickle pickle(buf, len); | 120 Pickle pickle(buf, len); |
| 112 void* iter = NULL; | 121 void* iter = NULL; |
| 113 | 122 |
| 114 int kind; | 123 int kind; |
| 115 if (!pickle.ReadInt(&iter, &kind)) | 124 if (!pickle.ReadInt(&iter, &kind)) |
| 116 goto error; | 125 goto error; |
| 117 | 126 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 _exit(0); | 372 _exit(0); |
| 364 } | 373 } |
| 365 } | 374 } |
| 366 | 375 |
| 367 RenderSandboxHostLinux::~RenderSandboxHostLinux() { | 376 RenderSandboxHostLinux::~RenderSandboxHostLinux() { |
| 368 if (init_) { | 377 if (init_) { |
| 369 HANDLE_EINTR(close(renderer_socket_)); | 378 HANDLE_EINTR(close(renderer_socket_)); |
| 370 HANDLE_EINTR(close(childs_lifeline_fd_)); | 379 HANDLE_EINTR(close(childs_lifeline_fd_)); |
| 371 } | 380 } |
| 372 } | 381 } |
| OLD | NEW |