fix(io): refuse truncated files in the VOL, async and MPI readers

The truncated-file check and the end-of-file clamp reached File,
LazyFile and MmapFile but not clawhdf5-io's readers, which still opened
truncated files and read past the recorded end of file. NativeVol
(open, and read_dataset for from_bytes), AsyncHDF5File::from_bytes and
MpiVol's collective read now view the file through the new
vol::hdf5_view: from the superblock to Superblock::data_end, refusing a
file shorter than that.

MpiVol's read is compiled only with the mpi-io feature, which needs an
MPI installation; it was not built here. The edit there only swaps its
two-line superblock setup for hdf5_view.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 01:30:56 -05:00
co-authored by Claude Opus 5.5
parent dd40bea467
commit 3938f7f8a2
4 changed files with 88 additions and 12 deletions
+5 -2
View File
@@ -343,8 +343,11 @@
(`chunked_read::collect_chunk_info_checked`).
- truncated files (`FormatError::TruncatedFile`, `Superblock::data_end`):
a file shorter than the end of file its superblock records is refused
("truncated file"), and nothing past that end is read. `File`,
`LazyFile` and `MmapFile` do this.
("truncated file"), and nothing past that end is read. Every reader
does this: `File`, `LazyFile` and `MmapFile`, and in `clawhdf5-io`
`NativeVol` (at `open`, and on read for `from_bytes`),
`AsyncHDF5File` and `MpiVol` (the MPI path is not built in CI: it
needs an MPI installation).
- the writer: `FileWriter::finish()` / `FileBuilder::finish()` refuse a
datatype the reader would refuse (`FormatError::SerializationError`,
"datatype cannot be written: ..."), such as a compound with a repeated