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

Unified Diff: chromeos/process_proxy/process_output_watcher.cc

Issue 1135823007: Prevent ProcessProxy from passing bad fds to ProcessOutputWatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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
« no previous file with comments | « chromeos/process_proxy/process_output_watcher.h ('k') | chromeos/process_proxy/process_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/process_proxy/process_output_watcher.cc
diff --git a/chromeos/process_proxy/process_output_watcher.cc b/chromeos/process_proxy/process_output_watcher.cc
index 906fe63440a3b84877fc65bb50553ced8720a723..17c1c9459a77dea6d4cb816493e2a2c4050f643b 100644
--- a/chromeos/process_proxy/process_output_watcher.cc
+++ b/chromeos/process_proxy/process_output_watcher.cc
@@ -55,6 +55,11 @@ size_t UTF8SizeFromLeadingByte(uint8 leading_byte) {
namespace chromeos {
+// static
+bool ProcessOutputWatcher::VerifyFileDescriptor(int fd) {
+ return (fd >= 0) && (fd < FD_SETSIZE);
+}
+
ProcessOutputWatcher::ProcessOutputWatcher(
int out_fd,
int stop_fd,
@@ -63,8 +68,8 @@ ProcessOutputWatcher::ProcessOutputWatcher(
out_fd_(out_fd),
stop_fd_(stop_fd),
on_read_callback_(callback) {
- VerifyFileDescriptor(out_fd_);
- VerifyFileDescriptor(stop_fd_);
+ CHECK(VerifyFileDescriptor(out_fd_));
+ CHECK(VerifyFileDescriptor(stop_fd_));
max_fd_ = std::max(out_fd_, stop_fd_);
// We want to be sure we will be able to add 0 at the end of the input, so -1.
read_buffer_capacity_ = arraysize(read_buffer_) - 1;
@@ -106,11 +111,6 @@ void ProcessOutputWatcher::WatchProcessOutput() {
}
}
-void ProcessOutputWatcher::VerifyFileDescriptor(int fd) {
- CHECK_LE(0, fd);
- CHECK_GT(FD_SETSIZE, fd);
-}
-
void ProcessOutputWatcher::ReadFromFd(ProcessOutputType type, int* fd) {
// We don't want to necessary read pipe until it is empty so we don't starve
// other streams in case data is written faster than we read it. If there is
« no previous file with comments | « chromeos/process_proxy/process_output_watcher.h ('k') | chromeos/process_proxy/process_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698