Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Linux] Do not try to call readdir() on a null DIR* in base::ProcessI…
Browse files Browse the repository at this point in the history
…terator.

BUG=581517
[email protected]

Review URL: https://codereview.chromium.org/1642663003 .

Cr-Commit-Position: refs/heads/master@{#371837}
(cherry picked from commit 0c97b34)

Review URL: https://codereview.chromium.org/1644693002 .

Cr-Commit-Position: refs/branch-heads/2623@{#166}
Cr-Branched-From: 92d7753-refs/heads/master@{#369907}
  • Loading branch information
rsesek committed Jan 27, 2016
1 parent 1c43f71 commit 7aa1d66
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion base/process/process_iterator_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,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;
Expand Down

0 comments on commit 7aa1d66

Please sign in to comment.