test: a v2 header message running into the checksum is refused, as in libhdf5

The review read libhdf5's H5O__chunk_deserialize as accepting a v2
message that runs up to 4 bytes into the chunk's checksum, since it
bounds message bodies by the whole chunk buffer. It does not accept it:
the message loop stops at the checksum, and the checksum read that
follows starts past it and overruns the chunk ("ran off end of input
buffer while decoding"). h5py refuses such files whether the message
runs 1, 4 or 5 bytes in, and so does clawhdf5, with its own error text.
No code change; the test pins the agreement and a comment records why.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 01:32:00 -05:00
co-authored by Claude Opus 5.5
parent 3938f7f8a2
commit 993214723e
2 changed files with 55 additions and 0 deletions
@@ -421,6 +421,13 @@ impl ObjectHeader {
};
pos += msg_header_size;
// `end` is where the messages stop and the checksum starts.
// libhdf5 bounds a message by the chunk including its checksum,
// but a message that runs into the checksum still fails there:
// its loop stops at the checksum, and reading the checksum from
// past its start overruns the chunk ("ran off end of input
// buffer while decoding"). Both refuse it; only the text
// differs.
if msg_data_size > end - pos {
return Err(FormatError::InvalidObjectHeader(
"message size exceeds buffer end",