Commit 0c97b34a authored by Robert Sesek's avatar Robert Sesek

[Linux] Do not try to call readdir() on a null DIR* in base::ProcessIterator.

BUG=581517
R=thakis@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#371837}
parent 9cb6b773
...@@ -61,18 +61,28 @@ bool GetProcCmdline(pid_t pid, std::vector<std::string>* proc_cmd_line_args) { ...@@ -61,18 +61,28 @@ bool GetProcCmdline(pid_t pid, std::vector<std::string>* proc_cmd_line_args) {
ProcessIterator::ProcessIterator(const ProcessFilter* filter) ProcessIterator::ProcessIterator(const ProcessFilter* filter)
: filter_(filter) { : filter_(filter) {
procfs_dir_ = opendir(internal::kProcDir); 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() { ProcessIterator::~ProcessIterator() {
if (procfs_dir_) { if (procfs_dir_) {
closedir(procfs_dir_); closedir(procfs_dir_);
procfs_dir_ = NULL; procfs_dir_ = nullptr;
} }
} }
bool ProcessIterator::CheckForNextProcess() { bool ProcessIterator::CheckForNextProcess() {
// TODO(port): skip processes owned by different UID // TODO(port): skip processes owned by different UID
if (!procfs_dir_) {
DLOG(ERROR) << "Skipping CheckForNextProcess(), no procfs_dir_";
return false;
}
pid_t pid = kNullProcessId; pid_t pid = kNullProcessId;
std::vector<std::string> cmd_line_args; std::vector<std::string> cmd_line_args;
std::string stats_data; std::string stats_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment