You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The vendored MetaIO MET_PerformUncompression (Modules/ThirdParty/MetaIO/src/MetaIO/src/metaUtils.cxx) validates the number of decompressed bytes but not that the zlib stream reached Z_STREAM_END. A compressed stream truncated exactly at the declared output size is therefore accepted, and its trailing Adler-32 checksum is never verified.
Surfaced by an automated review on #6692 (MetaIO 8c41a1d9 re-vendor, now merged).
Blocked on upstream
MetaIO is vendored from Kitware/MetaIO, so this must be fixed upstream and re-vendored — it must not be patched in-place in Modules/ThirdParty/MetaIO/ (an UpdateFromUpstream.sh run would overwrite a local edit).
Confirm the Z_STREAM_END check is present in the re-vendored metaUtils.cxx.
Verify ITKIOMeta tests still pass (the new upstream regression tests testMeta13ImageList / testMeta14ImageCompressed plus the module suite).
Root cause
When the decompressed data fills the destination buffer exactly, the last inflate() returns Z_OK and the next call (with avail_out == 0) returns Z_BUF_ERROR — which is < 0, so the loop exits, but Z_BUF_ERROR is deliberately excluded from the "Uncompress failed" diagnostic. Control reaches the final check with dest_pos == uncompressedDataSize and the function returns true, even though Z_STREAM_END was never reached. See the Greptile P1 thread on #6692 and Kitware/MetaIO#144 for the full trace.
Summary
The vendored MetaIO
MET_PerformUncompression(Modules/ThirdParty/MetaIO/src/MetaIO/src/metaUtils.cxx) validates the number of decompressed bytes but not that the zlib stream reachedZ_STREAM_END. A compressed stream truncated exactly at the declared output size is therefore accepted, and its trailing Adler-32 checksum is never verified.Surfaced by an automated review on #6692 (MetaIO
8c41a1d9re-vendor, now merged).Blocked on upstream
MetaIO is vendored from Kitware/MetaIO, so this must be fixed upstream and re-vendored — it must not be patched in-place in
Modules/ThirdParty/MetaIO/(anUpdateFromUpstream.shrun would overwrite a local edit).Z_STREAM_ENDguard) — must merge firstResolution steps (once Kitware/MetaIO#145 merges)
Modules/ThirdParty/MetaIO/UpdateFromUpstream.shto re-vendor MetaIO at the post-ITK 4.13.0 build from source fails to download castxml-linux.tar.gz #145 snapshot (two-parent vendor merge, per ITK ThirdParty conventions).Z_STREAM_ENDcheck is present in the re-vendoredmetaUtils.cxx.ITKIOMetatests still pass (the new upstream regression teststestMeta13ImageList/testMeta14ImageCompressedplus the module suite).Root cause
When the decompressed data fills the destination buffer exactly, the last
inflate()returnsZ_OKand the next call (withavail_out == 0) returnsZ_BUF_ERROR— which is< 0, so the loop exits, butZ_BUF_ERRORis deliberately excluded from the "Uncompress failed" diagnostic. Control reaches the final check withdest_pos == uncompressedDataSizeand the function returnstrue, even thoughZ_STREAM_ENDwas never reached. See the Greptile P1 thread on #6692 and Kitware/MetaIO#144 for the full trace.