Skip to content

fix off-by-one scanf width in filter_parse_component_name#10854

Open
jmestwa-coder wants to merge 1 commit into
thesofproject:mainfrom
jmestwa-coder:logger-filter-scan-bound
Open

fix off-by-one scanf width in filter_parse_component_name#10854
jmestwa-coder wants to merge 1 commit into
thesofproject:mainfrom
jmestwa-coder:logger-filter-scan-bound

Conversation

@jmestwa-coder

Copy link
Copy Markdown

sscanf writes one byte past comp_name when parsing a -F component name:

  • the format width is set to UUID_NAME_MAX_LEN, but a %N[...] conversion writes up to N characters plus a NUL
  • comp_name is only UUID_NAME_MAX_LEN bytes, so a name of that length overflows the stack buffer by one byte
    Capped the scan width at UUID_NAME_MAX_LEN - 1.

@sofci

sofci commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmestwa-coder can you add a proper commit message and sign off. Thanks !

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a stack-buffer off-by-one overflow in tools/logger’s -F component-name parsing by ensuring sscanf()’s scanset conversion cannot write a full UUID_NAME_MAX_LEN characters plus the terminating NUL into a UUID_NAME_MAX_LEN buffer.

Changes:

  • Cap the sscanf() width used for parsing component names to UUID_NAME_MAX_LEN - 1 to leave space for the NUL terminator.

Comment thread tools/logger/filter.c
Comment on lines 105 to +107
if (strlen(scan_format_string) == 0) {
ret = snprintf(scan_format_string, sizeof(scan_format_string),
"%%%d[^0-9* ]s", UUID_NAME_MAX_LEN);
"%%%d[^0-9* ]s", UUID_NAME_MAX_LEN - 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants