mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user