Skip to content

Add error checking to zstd HDF5 filter - #403

Closed
pimlu wants to merge 1 commit into
silx-kit:mainfrom
pimlu:geipel/zstd-check-errors
Closed

Add error checking to zstd HDF5 filter#403
pimlu wants to merge 1 commit into
silx-kit:mainfrom
pimlu:geipel/zstd-check-errors

Conversation

@pimlu

@pimlu pimlu commented Jul 29, 2026

Copy link
Copy Markdown

This PR adds error checking to the zstd HDF5 filter. 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.
@@ -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);

@pimlu pimlu Jul 29, 2026

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.

@t20100

t20100 commented Jul 30, 2026

Copy link
Copy Markdown
Member

Thanks for the Pull Request!

This projects embeds copies of third-party hdf5 filters.

For ZSTD, the upstream project is https://github.com/HDFGroup/hdf5_plugins/blob/master/ZSTD/src/H5Zzstd.c.
Please propose your fix to upstream first, we'll update the vendored version of the ZSTD filter once it is fixed upstream.

@pimlu

pimlu commented Jul 30, 2026

Copy link
Copy Markdown
Author

Oh thanks for pointing me in the right direction! I made a PR in the upstream hdf5_plugins, I will close this PR.

@pimlu pimlu closed this Jul 30, 2026
@t20100

t20100 commented Aug 1, 2026

Copy link
Copy Markdown
Member

Thanks!

For reference, upstream PR: HDFGroup/hdf5_plugins#280

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