Skip to content

bound chunk dimension count in H5P__dcrt_layout_dec - #6724

Open
naruto-lgtm wants to merge 1 commit into
HDFGroup:developfrom
naruto-lgtm:dcpl-chunk-rank-bound
Open

naruto-lgtm wants to merge 1 commit into
HDFGroup:developfrom
naruto-lgtm:dcpl-chunk-rank-bound

Conversation

@naruto-lgtm

Copy link
Copy Markdown
Contributor

Describe your changes

Cause: H5P__dcrt_layout_dec() decodes a chunked layout from an encoded property list (reached from the public H5Pdecode()). It reads the chunk rank as a single byte and only rejects zero, then writes that many dimensions into tmp_layout.u.chunk.dim[], a fixed array of H5O_LAYOUT_NDIMS (33) entries. A rank above that count overruns the stack struct and runs past the end of the input buffer. The object header layout message decoder (H5O__layout_decode()) already rejects ndims > H5O_LAYOUT_NDIMS; the property-list decoder did not.

Fix: reject a rank greater than H5O_LAYOUT_NDIMS before the decode loop, keeping the bound in the decoder where the untrusted count is consumed.

Repro: with ASan, H5Pdecode() on an encoded DCPL whose chunk-rank byte is set to 200 faults with a heap-buffer-overflow in H5P__dcrt_layout_dec(); after the change the same buffer is rejected with an error. A regression test covering this is added to test/enc_dec_plist.c.

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 Oct 9, 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.

@bmribler bmribler self-assigned this Oct 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

3 participants