Skip to content

Size opaque metadata buffer by checked element count in Mat_VarRead73 - #336

Open
naruto-lgtm wants to merge 3 commits into
tbeu:masterfrom
naruto-lgtm:mat73-opaque-meta-size
Open

naruto-lgtm wants to merge 3 commits into
tbeu:masterfrom
naruto-lgtm:mat73-opaque-meta-size

Conversation

@naruto-lgtm

Copy link
Copy Markdown
Contributor

Repro: read a v7.3 file with an unknown-class integer dataset (classified MAT_C_OPAQUE) whose dataspace element count is near the integer limits.
Cause: the opaque branch sizes the uint32 metadata buffer with a raw (size_t)nelems * sizeof(mat_uint32_t), but H5Dread fills nelems elements from the H5S_ALL selection, so the byte multiply wraps (and nelems truncates on a 32-bit size_t) and H5Dread writes past the allocation.
Fix: size the buffer with the overflow-checked Mul used by the other readers and skip the read when the count would overflow or truncate, keeping the allocation in step with the H5Screate_simple element count.

@naruto-lgtm

Copy link
Copy Markdown
Contributor Author

any update?

Comment thread src/mat73.c Outdated
@tbeu
tbeu force-pushed the mat73-opaque-meta-size branch 2 times, most recently from 6550270 to 67ce45c Compare October 6, 2026 15:44
@naruto-lgtm

Copy link
Copy Markdown
Contributor Author

gentle ping

@tbeu
tbeu force-pushed the mat73-opaque-meta-size branch from 67ce45c to a5ccf61 Compare October 20, 2026 15:54
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.

2 participants