bound the table title read in H5TBinsert_field/H5TBdelete_field - #6637
Open
naruto-lgtm wants to merge 2 commits into
Open
naruto-lgtm wants to merge 2 commits into
naruto-lgtm wants to merge 2 commits into
Conversation
naruto-lgtm
requested review from
brtnfld,
glennsong09,
hyoklee,
lrknox and
mattjala
as code owners
August 23, 2026 14:11
Contributor
hyoklee
previously approved these changes
Aug 25, 2026
| attribute, so opening a table whose TITLE is longer than that buffer | ||
| overran the stack. The title is now read into a buffer sized to the stored | ||
| attribute and copied back with a length cap. | ||
|
|
Member
There was a problem hiding this comment.
Fix run-on sentences:
Both functions read a table's TITLE attribute back using H5TBAget_title(), which passes the caller's buffer straight to H5Aread(). The buffer is a fixed 255-byte stack array, but H5Aread() copies the whole stored attribute. Consequently, opening a table with a TITLE longer than the buffer overran the stack. The title is now read into a buffer sized to the stored attribute and copied back with a length cap.
Contributor
Author
There was a problem hiding this comment.
Done, applied your wording.
hyoklee
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Repro: open a table whose TITLE attribute is longer than 254 bytes, then call H5TBinsert_field or H5TBdelete_field on it.
Cause: both read the title back with H5TBAget_title(), which passes their fixed char[255] straight to H5Aread(). H5Aread() copies the whole stored attribute, so a longer title runs off the stack buffer (ASan reports a 600-byte write into table_title[255]).
Fix: read the title through a bounded helper that sizes its own buffer to the stored attribute and copies back a length-capped, NUL-terminated string. H5TBAget_title() has no length argument so it cannot be made safe in place; the fix lives at the two callers that pair it with a fixed buffer.
Issue ticket number (GitHub or JIRA)
N/A
Checklist before requesting a review