Skip to content

Add error checking to zstd hdf5 plugin - #280

Open
pimlu wants to merge 1 commit into
HDFGroup:masterfrom
pimlu:geipel/zstd-check-errors
Open

Add error checking to zstd hdf5 plugin#280
pimlu wants to merge 1 commit into
HDFGroup:masterfrom
pimlu:geipel/zstd-check-errors

Conversation

@pimlu

@pimlu pimlu commented Jul 30, 2026

Copy link
Copy Markdown

This PR adds error checking to the zstd hdf5 plugin. Previously it would return uninitialized memory from malloc when any zstd error occurred.

It also prevents proceeding with the result of malloc(0) in the abnormal case where decompSize == 0.

This PR adds error checking to the zstd hdf5 plugin.  Previously it would return uninitialized memory from malloc when any zstd error occurred.

It also prevents proceeding with the result of malloc(0) in the abnormal case where decompSize == 0.
@pimlu
pimlu requested review from mkitti and nhz2 as code owners July 30, 2026 18:40
Comment thread ZSTD/src/H5Zzstd.c
@@ -66,10 +66,16 @@ H5Z_filter_zstd(unsigned int flags, size_t cd_nelmts, const unsigned int cd_valu
if (flags & H5Z_FLAG_REVERSE) {
/* We're decompressing */
size_t decompSize = ZSTD_getFrameContentSize(*buf, origSize);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Technically decompSize should be an unsigned long long but on 64-bit systems the outcome is the same. Let me know if I should update this in the same PR.

@mkitti mkitti Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please fix that here.

Below, an unknown content size should not be treated as an error. That is a perfectly valid situation for Zstandard compressed data.

We may need to use the streaming API to complete decompression, however.

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