fix(format): refuse a chunk layout whose element size is not the datatype's

A chunked layout records the element size as its last dimension, and
libhdf5 refuses a dataset whose datatype has another size
(H5D__chunk_set_sizes: "stored datatype size in chunk layout does not
match datatype description"). clawhdf5 ignored the recorded size and
read the chunks anyway, for v3 and v4 layouts. The check runs on every
chunked read (read_chunked_data*, read_raw_data_selection) and compares
against the stored size: a variable-length element is 4 + offset size
+ 4 bytes, not Datatype::type_size's 16.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 01:29:26 -05:00
co-authored by Claude Opus 5.5
parent afae86f3ea
commit dd40bea467
5 changed files with 154 additions and 3 deletions
+1
View File
@@ -303,6 +303,7 @@ pub fn read_raw_data_selection(
use crate::selection::Selection;
crate::partial_read::validate(selection, &dataspace.dimensions)?;
crate::chunked_read::check_chunk_element_size(layout, datatype, offset_size)?;
// Read only what the selection's bounding box touches when that is
// possible; everything below is the decode-everything-then-pick path,