Skip to content

clamp path::subpath arguments to component count - #320

Closed
aouxwoux wants to merge 2 commits into
marzer:masterfrom
aouxwoux:fix/path-subpath-bounds
Closed

aouxwoux wants to merge 2 commits into
marzer:masterfrom
aouxwoux:fix/path-subpath-bounds

Conversation

@aouxwoux

@aouxwoux aouxwoux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

what changed

  • clamp \start\ and \length\ in \path::subpath(size_t, size_t)\ to \components_.size()\ and use \ptrdiff_t\ cast for iterator offsets.
  • add unit tests covering out-of-range bounds, full slice identity, single-component paths, and component type preservation.
  • pin linux ci runner to \ubuntu-22.04\ in \ci.yaml\ to match \lld-14\ package availability on github actions.
  • add contributor entry to \README.md.
  • regenerate single-header \ oml.hpp.

why

\path::subpath(size_t, size_t)\ directly computed iterators without validating either argument against \components_.size(). when \start >= components_.size()\ or when \length\ exceeded remaining components, iterators past \end()\ were passed to \std::vector::insert, triggering an out-of-bounds heap read (#319).

clamping \start\ and \length\ prevents past-the-end iterator arithmetic, matching the boundary handling of \ runcate()\ and \leaf().

checks

  • \git diff --check\ passes.
  • \python3 tools/ci_single_header_check.py\ passes.
  • full meson test suite passes (all 9 locales passed, 46,971 assertions in 54 test cases).
  • standalone AddressSanitizer and UndefinedBehaviorSanitizer test passes cleanly.
  • all 12 linux and windows github actions matrix jobs pass.

fixes #319

@marzer marzer 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.

Looks good modulo the CI change.

Comment thread .github/workflows/ci.yaml Resolved
marzer pushed a commit that referenced this pull request Nov 4, 2026
@marzer

marzer commented Nov 4, 2026

Copy link
Copy Markdown
Owner

@aouxwoux you happened to be contributing this as I was cooking up a pretty major refactor/modernization on another branch, which I have now merged. Rather than force you to deal with rebasing and merge conflicts, I've cherry-picked it myself as commit 86e991d, keeping you as the author.

Thanks for the contribution!

@marzer marzer closed this Nov 4, 2026
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.

Out-of-bounds read in toml::path::subpath(size_t, size_t) due to missing bounds clamping

2 participants