Skip to content

Commit e65f99e

Browse files
committed
hl: fix incorrect hvl_t comments in H5DS.c and CHANGELOG
VL strings use char* in memory, not hvl_t (which is only for VL sequences). Correct two comments in H5DS.c and the CHANGELOG entry per jhendersonHDF review on PR HDFGroup#6371.
1 parent e5286b5 commit e65f99e

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

hl/src/H5DS.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,8 +2262,9 @@ H5DSis_scale(hid_t did)
22622262
is_ds = 0;
22632263
goto out;
22642264
}
2265-
/* reject VLEN strings; H5Aread into a char* buffer would write an hvl_t
2266-
instead of character data, so this cannot be a dimension scale */
2265+
/* reject VLEN strings; H5Aread into a char* buffer would overwrite it
2266+
with a heap-allocated char* pointer rather than the string content,
2267+
so this cannot be a dimension scale */
22672268
if ((isvl = H5Tis_variable_str(tid)) < 0)
22682269
goto out;
22692270
if (isvl > 0) {
@@ -2485,9 +2486,10 @@ H5DS_is_reserved(hid_t did, bool *is_reserved)
24852486
if (H5T_STRING != H5Tget_class(tid))
24862487
goto error;
24872488

2488-
/* Reject VLEN strings; H5Aread into a char* buffer would write an hvl_t,
2489-
* not character data. Treat as an error for consistency with the
2490-
* existing non-NULLTERM rejection below. */
2489+
/* Reject VLEN strings; H5Aread into a char* buffer would overwrite it
2490+
* with a heap-allocated char* pointer rather than the string content.
2491+
* Treat as an error for consistency with the existing non-NULLTERM
2492+
* rejection below. */
24912493
if (H5Tis_variable_str(tid) > 0)
24922494
goto error;
24932495

release_docs/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ We would like to thank the many HDF5 community members who contributed to this r
215215
Additional fixes applied to all four routines:
216216

217217
- **VLEN-string CLASS attributes are now explicitly rejected.** Previously, reading a VLEN-typed
218-
attribute into a fixed `char *` buffer would write an `hvl_t` struct over the character data,
219-
which is undefined behaviour and could corrupt memory or produce garbage comparison results.
218+
attribute into a fixed `char *` buffer would overwrite it with a heap-allocated `char *` pointer
219+
rather than the string content, which is undefined behaviour and could corrupt memory or produce
220+
garbage comparison results.
220221
`H5DSis_scale()`, `H5IMis_image()`, and `H5IMis_palette()` now return 0 (not a scale/image/palette)
221222
for a VLEN CLASS attribute. `H5DS_is_reserved()` (an internal routine called by `H5DSattach_scale()`)
222223
returns FAIL, so `H5DSattach_scale()` will return FAIL for a dataset whose CLASS attribute uses a

0 commit comments

Comments
 (0)