OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/nacl/browser/nacl_browser.h" | 5 #include "components/nacl/browser/nacl_browser.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_proxy.h" | 9 #include "base/files/file_proxy.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 } | 106 } |
107 | 107 |
108 // Crash throttling parameters. | 108 // Crash throttling parameters. |
109 const size_t kMaxCrashesPerInterval = 3; | 109 const size_t kMaxCrashesPerInterval = 3; |
110 const int64 kCrashesIntervalInSeconds = 120; | 110 const int64 kCrashesIntervalInSeconds = 120; |
111 | 111 |
112 } // namespace | 112 } // namespace |
113 | 113 |
114 namespace nacl { | 114 namespace nacl { |
115 | 115 |
116 base::File OpenNaClExecutableImpl(const base::FilePath& file_path) { | 116 base::File OpenNaClReadExecImpl(const base::FilePath& file_path, |
117 bool is_executable) { | |
117 // Get a file descriptor. On Windows, we need 'GENERIC_EXECUTE' in order to | 118 // Get a file descriptor. On Windows, we need 'GENERIC_EXECUTE' in order to |
118 // memory map the executable. | 119 // memory map the executable. |
119 // IMPORTANT: This file descriptor must not have write access - that could | 120 // IMPORTANT: This file descriptor must not have write access - that could |
120 // allow a NaCl inner sandbox escape. | 121 // allow a NaCl inner sandbox escape. |
121 base::File file(file_path, | 122 base::File file(file_path, |
123 is_executable ? | |
Nick Bray (chromium)
2014/06/27 21:03:16
Nit: build the flags before the call to avoid redu
jvoung (off chromium)
2014/06/27 22:30:08
Done.
| |
122 (base::File::FLAG_OPEN | | 124 (base::File::FLAG_OPEN | |
123 base::File::FLAG_READ | | 125 base::File::FLAG_READ | |
124 base::File::FLAG_EXECUTE)); // Windows only flag. | 126 base::File::FLAG_EXECUTE) : // Windows only flag. |
127 (base::File::FLAG_OPEN | | |
128 base::File::FLAG_READ)); | |
125 if (!file.IsValid()) | 129 if (!file.IsValid()) |
126 return file.Pass(); | 130 return file.Pass(); |
127 | 131 |
128 // Check that the file does not reference a directory. Returning a descriptor | 132 // Check that the file does not reference a directory. Returning a descriptor |
129 // to an extension directory could allow an outer sandbox escape. openat(...) | 133 // to an extension directory could allow an outer sandbox escape. openat(...) |
130 // could be used to traverse into the file system. | 134 // could be used to traverse into the file system. |
131 base::File::Info file_info; | 135 base::File::Info file_info; |
132 if (!file.GetInfo(&file_info) || file_info.is_directory) | 136 if (!file.GetInfo(&file_info) || file_info.is_directory) |
133 return base::File(); | 137 return base::File(); |
134 | 138 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 bool NaClBrowser::IsThrottled() { | 558 bool NaClBrowser::IsThrottled() { |
555 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 559 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
556 if (crash_times_.size() != kMaxCrashesPerInterval) { | 560 if (crash_times_.size() != kMaxCrashesPerInterval) { |
557 return false; | 561 return false; |
558 } | 562 } |
559 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); | 563 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); |
560 return delta.InSeconds() <= kCrashesIntervalInSeconds; | 564 return delta.InSeconds() <= kCrashesIntervalInSeconds; |
561 } | 565 } |
562 | 566 |
563 } // namespace nacl | 567 } // namespace nacl |
OLD | NEW |