Skip to content

[core] Protect a string search from running out of bounds.#21320

Merged
hageboeck merged 1 commit intoroot-project:masterfrom
hageboeck:outOfBounds_TClassEdit
Feb 23, 2026
Merged

[core] Protect a string search from running out of bounds.#21320
hageboeck merged 1 commit intoroot-project:masterfrom
hageboeck:outOfBounds_TClassEdit

Conversation

@hageboeck
Copy link
Copy Markdown
Member

When running gtest-tree-ntuple-ntuple-type-name in address sanitizer, the check for the "const" qualifier ran out of bounds, because the cursor in TClassEdit.cxx:1793 was already at the end of the string, and "next" was one character after its end:

"std::vector<Double32_t[3]   > [10 ]  "
                                       ^

strcmp isn't designed for this case, so this commit adds length checks
before all "strcmp(base+offset, ...)" patterns.

I believe the test worked because the garbage that's read in memory is almost always != 'c' ('o', 'n', ...), and so the comparison is (usually) guaranteed to fail -- until it doesn't.

When running gtest-tree-ntuple-ntuple-type-name in address sanitizer,
the check for the "const" qualifier ran out of bounds, because the
cursor in TClassEdit.cxx:1793 was already at the end of the string, and
"next" was one character after its end:
"std::vector<Double32_t[3]   > [10 ]  "
                                       ^
strcmp isn't designed for this case, so this commit adds length checks
before all "strcmp(base+offset, ...)" patterns.
@hageboeck hageboeck self-assigned this Feb 19, 2026
@ferdymercury
Copy link
Copy Markdown
Collaborator

Thanks!
Maybe a bit related:
#9029
#10454

@hageboeck
Copy link
Copy Markdown
Member Author

Thanks! Maybe a bit related: #9029 #10454

Unfortunately not enough related that I would have time to go after those. 😅

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 19, 2026

Test Results

    22 files      22 suites   3d 6h 36m 25s ⏱️
 3 795 tests  3 790 ✅ 0 💤 5 ❌
76 350 runs  76 345 ✅ 0 💤 5 ❌

For more details on these failures, see this check.

Results for commit b09b756.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

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

Thanks.

@hageboeck hageboeck added the skip code analysis Skip the code analysis CI steps for this PR, including verifying clang-formatting and running Ruff. label Feb 19, 2026
@hageboeck hageboeck merged commit e83de98 into root-project:master Feb 23, 2026
72 of 79 checks passed
@hageboeck hageboeck deleted the outOfBounds_TClassEdit branch February 23, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip code analysis Skip the code analysis CI steps for this PR, including verifying clang-formatting and running Ruff.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants