Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create memory safe version of H5Dread_chunk() #5224

Open
fortnern opened this issue Jan 10, 2025 · 0 comments
Open

Create memory safe version of H5Dread_chunk() #5224

fortnern opened this issue Jan 10, 2025 · 0 comments
Milestone

Comments

@fortnern
Copy link
Member

H5Dread_chunk() currently has the signature: herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf);

This is potentially not memory safe because hte caller does not specify the size of buf. This is especialy problematic because the fitler can potentially increase the size of the chunk, meaning the only way for a caller to definitely know how big buf needs to be is to call H5Dget_chunk_info() first. We should add a size parameter to H5Dread_chunk(), which the caller initializes with the size of buf, and on exit contains the size of the filtered chunk (the needed size of buf). If the buffer is not big enough to read the entire chunk, the contents of buf are unchanged. This would allow the caller to pass a buffer they think is big enough without creating memory (and potentially security) errors if they're wrong and without needed to call H5Dget_Chunk_info() every time, which adds overhead and thereby partially defeats the purpose of the direct chunk I/O interface.

@fortnern fortnern added this to the 2.0.0 milestone Jan 10, 2025
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

No branches or pull requests

1 participant