summaryrefslogtreecommitdiffstats
path: root/test/tmisc.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-04-30 19:47:51 (GMT)
committerGitHub <noreply@github.com>2021-04-30 19:47:51 (GMT)
commit73bb382e9e77ca9847c09dff37b9e2338f26bbb8 (patch)
tree85e726e1aae576dc13ac76da36c92305c669ec92 /test/tmisc.c
parent7ab97037a0f64a583a6c7d4064d92a963cdfd843 (diff)
downloadhdf5-73bb382e9e77ca9847c09dff37b9e2338f26bbb8.zip
hdf5-73bb382e9e77ca9847c09dff37b9e2338f26bbb8.tar.gz
hdf5-73bb382e9e77ca9847c09dff37b9e2338f26bbb8.tar.bz2
Fixes crashes when size_hint > UINT32_MAX is passed to H5Gcreate1 (#611)
* Committing clang-format changes * Fixes incorrect size_hint handling in H5Gcreate1 * Updates the size hint type for group creation * Updates the RELEASE.txt note * Revert "Updates the RELEASE.txt note" This reverts commit 3df386acca806d652bbe2209f7c4503b30f068ff. * Reverts previous behavior to use a uint32_t struct field * Updates RELEASE.txt Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/tmisc.c')
-rw-r--r--test/tmisc.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/tmisc.c b/test/tmisc.c
index 03f9952..51e203a 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -4088,9 +4088,31 @@ test_misc23(void)
H5E_END_TRY;
VERIFY(tmp_id, FAIL, "H5Gcreate1");
- tmp_id = H5Gcreate1(file_id, "/A/grp", (size_t)0);
+ /* Make sure that size_hint values that can't fit into a 32-bit
+ * unsigned integer are rejected. Only necessary on systems where
+ * size_t is a 64-bit type.
+ */
+ if (SIZE_MAX > UINT32_MAX) {
+ H5E_BEGIN_TRY
+ {
+ tmp_id = H5Gcreate1(file_id, "/size_hint_too_large", SIZE_MAX);
+ }
+ H5E_END_TRY;
+ VERIFY(tmp_id, FAIL, "H5Gcreate1");
+ }
+
+ /* Make sure the largest size_hint value works */
+ H5E_BEGIN_TRY
+ {
+ tmp_id = H5Gcreate1(file_id, "/largest_size_hint", UINT32_MAX);
+ }
+ H5E_END_TRY;
CHECK(tmp_id, FAIL, "H5Gcreate1");
+ status = H5Gclose(tmp_id);
+ CHECK(status, FAIL, "H5Gclose");
+ tmp_id = H5Gcreate1(file_id, "/A/grp", (size_t)0);
+ CHECK(tmp_id, FAIL, "H5Gcreate1");
status = H5Gclose(tmp_id);
CHECK(status, FAIL, "H5Gclose");
@@ -4103,7 +4125,6 @@ test_misc23(void)
tmp_id = H5Dcreate1(file_id, "/A/dset", type_id, space_id, create_id);
CHECK(tmp_id, FAIL, "H5Dcreate1");
-
status = H5Dclose(tmp_id);
CHECK(status, FAIL, "H5Dclose");
#endif /* H5_NO_DEPRECATED_SYMBOLS */