Skip to content

bound the table title read in H5TBinsert_field/H5TBdelete_field - #6637

Open
naruto-lgtm wants to merge 2 commits into
HDFGroup:developfrom
naruto-lgtm:h5tb-title-bound
Open

naruto-lgtm wants to merge 2 commits into
HDFGroup:developfrom
naruto-lgtm:h5tb-title-bound

Conversation

@naruto-lgtm

Copy link
Copy Markdown
Contributor

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

  • My code conforms to the guidelines in CONTRIBUTING.md
  • I made an entry in release_docs/CHANGELOG.md (bug fixes, new features)
  • I added a test (bug fixes, new features)

@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

@github-actions
github-actions Bot removed the request for review from mattjala August 23, 2026 14:14
hyoklee
hyoklee previously approved these changes Aug 25, 2026
Comment thread release_docs/CHANGELOG.md
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.

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, applied your wording.

@hyoklee hyoklee added the Component - C Library Core C library issues (usually in the src directory) label Aug 25, 2026
@hyoklee hyoklee moved this from To be triaged to Planning in HDF5 - TRIAGE & TRACK Aug 25, 2026
@hyoklee hyoklee added this to the Backlog milestone Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - C Library Core C library issues (usually in the src directory)

Projects

Status: Planning

Development

Successfully merging this pull request may close these issues.

3 participants