Skip to content

/proc/PID/stat mishandles whitespace #678

Open

Description

@jwilk

ProcParser::ParseProcPIDStat() mishandles whitespace characters in the comm field in multiple ways:

if (std::getline(ifs, line)) {

This reads only one line, but comm can contain newline characters.

std::vector<std::string_view> split = absl::StrSplit(line, " ", absl::SkipWhitespace());

As I understand it, with SkipWhitespace, multiple consecutive spaces will treated as if it was just one. But for command_offset, every space is counted.

if (split.size() < kProcStatNumFields) {

This doesn't take spaces into account at all.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions