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

Unified Diff: base/process/process_iterator_linux.cc

Issue 1642663003: [Linux] Do not try to call readdir() on a null DIR* in base::ProcessIterator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_iterator_linux.cc
diff --git a/base/process/process_iterator_linux.cc b/base/process/process_iterator_linux.cc
index a9d044c53824f7cd74f1a1c9717a51f0fefc5dfb..95275c29abff7c966c24810df4bfd1bc3b28322a 100644
--- a/base/process/process_iterator_linux.cc
+++ b/base/process/process_iterator_linux.cc
@@ -59,18 +59,28 @@ bool GetProcCmdline(pid_t pid, std::vector<std::string>* proc_cmd_line_args) {
ProcessIterator::ProcessIterator(const ProcessFilter* filter)
: filter_(filter) {
procfs_dir_ = opendir(internal::kProcDir);
+ if (!procfs_dir_) {
+ // On Android, SELinux may prevent reading /proc. See
+ // https://crbug.com/581517 for details.
+ PLOG(ERROR) << "opendir " << internal::kProcDir;
+ }
}
ProcessIterator::~ProcessIterator() {
if (procfs_dir_) {
closedir(procfs_dir_);
- procfs_dir_ = NULL;
+ procfs_dir_ = nullptr;
}
}
bool ProcessIterator::CheckForNextProcess() {
// TODO(port): skip processes owned by different UID
+ if (!procfs_dir_) {
+ DLOG(ERROR) << "Skipping CheckForNextProcess(), no procfs_dir_";
+ return false;
+ }
+
pid_t pid = kNullProcessId;
std::vector<std::string> cmd_line_args;
std::string stats_data;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698