Fix NULL pointer access when H5A_operator2_t is NULL (#6541)

* Fix NULL pointer access when H5A_operator2_t is NULL

Passing NULL for the callback function pointer to H5Aiterate2 and
H5Aiterate_by_name was not detected, leading to a subsequent access
of an uninitialized pointer. Add a check for this "no operator
specified" case in both functions so they fail gracefully instead.

Fixes GHSA-r7g4-hv2f-5c66 - CVE-2025-9274

* Fix format

* Fix Java test to handle NULL callback to H5Aiterate2
This commit is contained in:
bmribler
2026-07-21 14:21:38 -04:00
committed by GitHub
parent 9eaec3e81a
commit 8a48c7ced8
5 changed files with 29 additions and 3 deletions
+8
View File
@@ -7608,6 +7608,14 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, H5_index_t idx
H5E_END_TRY
VERIFY(ret, FAIL, "H5Aiterate_by_name");
/* Test passing null pointer for callback */
H5E_BEGIN_TRY
{
ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, NULL, NULL, H5P_DEFAULT);
}
H5E_END_TRY
VERIFY(ret, FAIL, "H5Aiterate_by_name");
/* Retrieve current # of errors */
if (old_nerrs == GetTestNumErrs())
return (0);
+8
View File
@@ -539,6 +539,14 @@ test_iter_attr(hid_t fapl, bool new_format)
H5E_END_TRY
VERIFY(ret, FAIL, "H5Aiterate2");
/* Test passing null pointer for callback */
H5E_BEGIN_TRY
{
ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, NULL, &info);
}
H5E_END_TRY
VERIFY(ret, FAIL, "H5Aiterate2");
/* Test all attributes on dataset, when callback always returns 0 */
info.command = RET_ZERO;
idx = 0;