Skip to content

Crash when parsing empty tokens #6

@WWWjiahui

Description

@WWWjiahui

When parsing lines that contain empty tokens, the parser triggers a stack-buffer-overflow in SettingsParser::parseLine, leading to program crash. This occurs because an empty token is passed to the char-conversion code which accesses input[0] without checking for empty string.

Create a file with contents:

  charsv,,

and run fuzzing tests

Observed:

Image

Root cause:
The crash was triggered inside SettingsParser::parseLine, which reads line[index] without checking index < line.size().

Fix:
Add explicit boundary checks in all loops in parseLine that access line[index], and protect the substr call

while (index < line.size() && std::isspace(line[index], m_locale)) index++;
...
const std::string value = (index < line.size()) ? line.substr(index) : std::string();

Impact:

  • Crash for user parsing crafted input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions