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

Side by Side Diff: ipc/file_descriptor_set_posix.cc

Issue 2822013: Revert 49989 - x (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 | « chrome/browser/cocoa/objc_zombie.mm ('k') | ipc/ipc_channel_posix.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "ipc/file_descriptor_set_posix.h" 5 #include "ipc/file_descriptor_set_posix.h"
6 6
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 12 matching lines...) Expand all
23 // message should have been transmitted, then closing those with close 23 // message should have been transmitted, then closing those with close
24 // flags set mirrors the expected behaviour. 24 // flags set mirrors the expected behaviour.
25 // 25 //
26 // If this message was received with more descriptors than expected 26 // If this message was received with more descriptors than expected
27 // (which could a DOS against the browser by a rogue renderer) then all 27 // (which could a DOS against the browser by a rogue renderer) then all
28 // the descriptors have their close flag set and we free all the extra 28 // the descriptors have their close flag set and we free all the extra
29 // kernel resources. 29 // kernel resources.
30 for (unsigned i = consumed_descriptor_highwater_; 30 for (unsigned i = consumed_descriptor_highwater_;
31 i < descriptors_.size(); ++i) { 31 i < descriptors_.size(); ++i) {
32 if (descriptors_[i].auto_close) 32 if (descriptors_[i].auto_close)
33 if (HANDLE_EINTR(close(descriptors_[i].fd)) < 0) 33 HANDLE_EINTR(close(descriptors_[i].fd));
34 PLOG(ERROR) << "close";
35 } 34 }
36 } 35 }
37 36
38 bool FileDescriptorSet::Add(int fd) { 37 bool FileDescriptorSet::Add(int fd) {
39 if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE) 38 if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE)
40 return false; 39 return false;
41 40
42 struct base::FileDescriptor sd; 41 struct base::FileDescriptor sd;
43 sd.fd = fd; 42 sd.fd = fd;
44 sd.auto_close = false; 43 sd.auto_close = false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return true; 106 return true;
108 } 107 }
109 108
110 return false; 109 return false;
111 } 110 }
112 111
113 void FileDescriptorSet::CommitAll() { 112 void FileDescriptorSet::CommitAll() {
114 for (std::vector<base::FileDescriptor>::iterator 113 for (std::vector<base::FileDescriptor>::iterator
115 i = descriptors_.begin(); i != descriptors_.end(); ++i) { 114 i = descriptors_.begin(); i != descriptors_.end(); ++i) {
116 if (i->auto_close) 115 if (i->auto_close)
117 if (HANDLE_EINTR(close(i->fd)) < 0) 116 HANDLE_EINTR(close(i->fd));
118 PLOG(ERROR) << "close";
119 } 117 }
120 descriptors_.clear(); 118 descriptors_.clear();
121 consumed_descriptor_highwater_ = 0; 119 consumed_descriptor_highwater_ = 0;
122 } 120 }
123 121
124 void FileDescriptorSet::SetDescriptors(const int* buffer, unsigned count) { 122 void FileDescriptorSet::SetDescriptors(const int* buffer, unsigned count) {
125 DCHECK_LE(count, MAX_DESCRIPTORS_PER_MESSAGE); 123 DCHECK_LE(count, MAX_DESCRIPTORS_PER_MESSAGE);
126 DCHECK_EQ(descriptors_.size(), 0u); 124 DCHECK_EQ(descriptors_.size(), 0u);
127 DCHECK_EQ(consumed_descriptor_highwater_, 0u); 125 DCHECK_EQ(consumed_descriptor_highwater_, 0u);
128 126
129 descriptors_.reserve(count); 127 descriptors_.reserve(count);
130 for (unsigned i = 0; i < count; ++i) { 128 for (unsigned i = 0; i < count; ++i) {
131 struct base::FileDescriptor sd; 129 struct base::FileDescriptor sd;
132 sd.fd = buffer[i]; 130 sd.fd = buffer[i];
133 sd.auto_close = true; 131 sd.auto_close = true;
134 descriptors_.push_back(sd); 132 descriptors_.push_back(sd);
135 } 133 }
136 } 134 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/objc_zombie.mm ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698