Skip to content

Fix out-of-bounds cursor increment in pop_token() - #222

Merged
troglobit merged 1 commit into
troglobit:masterfrom
94xhn:fix/pop-token-oob-access
Jul 18, 2026
Merged

Fix out-of-bounds cursor increment in pop_token()#222
troglobit merged 1 commit into
troglobit:masterfrom
94xhn:fix/pop-token-oob-access

Conversation

@94xhn

@94xhn 94xhn commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

While parsing tokens from the configuration file lines (and IPC parameters), \pop_token()\ traverses to the end of a token. When parsing the last token on a line, \end\ will point to the natural null terminator \0. Unconditionally incrementing the cursor *line = end + 1\ makes the next parsing loop reference memory past the buffer boundaries (an out-of-bounds read). If the adjacent memory is dirty (not null or whitespaces), \pop_token\ will process it as a token and write a null terminator *end = 0\ further out-of-bounds. This patch checks if *end == '\0'\ first. If it is, *line\ is safely set to \NULL\ to prevent subsequent parsing loops from running off the buffer. Otherwise, it proceeds with the usual null termination and cursor increment.

Signed-off-by: yi chen <94xhn1@gmail.com>

@troglobit troglobit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice catch!

@troglobit
troglobit merged commit 9f07e9c into troglobit:master Jul 18, 2026
2 checks passed
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.

2 participants