Repository navigation
v0.14.2 — metadata bounds and 32-bit builds
Security patch: every allocation sized from file metadata is now bounded, and 32-bit builds work again.
What this fixes
A corrupted metadata byte could make the library request terabytes and die with a fatal
out-of-memory error, which Go cannot recover from. Every such allocation is now validated against
the bytes actually present before it happens, and block reads go through one checked funnel modelled
on the C library's H5F_block_read and H5D__contig_check.
// Windows, Linux and macOS, 32- and 64-bit
go get github.com/scigolib/hdf5@v0.14.2Security
- Bounds on every allocation sized from file metadata (issue #68). Contiguous dataset reads, the
float64 conversion buffer, fixed and variable-length attributes, the compound, string and
variable-length readers, the local heap, the global heap, the fractal-heap blocks and hyperslab
chunk reads are all validated against the bytes present before allocating. - Defects found by the new fuzz harness and the review, all fixed: a truncated dataspace header
panic, a compound member offset used as a slice bound, three readers sizing result slices before
checking the data, a variable-length datatype smaller than its heap reference, a link name length
that wrapped an integer check, and a 65535-byte filter name that rounded to zero inuint16.
Bug Fixes
- 32-bit targets compile again (issue #66):
linux/386,linux/arm(GOARM=6) and
windows/386build and passgo vetin CI. - Version 4 chunked layouts are parsed correctly. Six reference files were previously read with
an empty chunk grid; a chunk index the library cannot traverse now returns a clear error instead
of being read as a v1 B-tree. - Version 4 chunk layout bodies are validated as the C decoder does: unknown flags, a rank above
H5O_LAYOUT_NDIMS, a zero or oversized encoded dimension width, a zero chunk dimension and
truncated bodies are rejected. - Hyperslab chunk iteration validates the chunk-count span; chunk reads validate the size from the
B-tree key. Both could previously panic on corrupt metadata. - LZF padding and the read-modify-write fractal-heap direct block are bounded like every other
chunk-sized allocation.
Changed
File.Reader()returns a read-only view bounded by the file size: a read outside the file now
returns an error instead of the platform reader's short read.
Verification
go test ./... and go test -race ./... (Linux) pass; the official HDF5 reference suite and the C
interop tests (h5dump, h5ls, h5py, h5repack) pass; golangci-lint reports no issues; both CI
fuzz targets run clean for 60 seconds each.
Full changelog: https://github.com/scigolib/hdf5/blob/main/CHANGELOG.md
Compare: v0.14.1...v0.14.2