summaryrefslogtreecommitdiffstats
path: root/src/H5Gobj.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2024-03-08 02:36:58 (GMT)
committerGitHub <noreply@github.com>2024-03-08 02:36:58 (GMT)
commitb0af7cf58bff90a152a6a61071d7fce41712ffdc (patch)
treee08f18622db6e7ba253030e403badb8168bb9808 /src/H5Gobj.c
parentf24496074ffccde0c96bdfa1895610fb1b9835a0 (diff)
downloadhdf5-b0af7cf58bff90a152a6a61071d7fce41712ffdc.zip
hdf5-b0af7cf58bff90a152a6a61071d7fce41712ffdc.tar.gz
hdf5-b0af7cf58bff90a152a6a61071d7fce41712ffdc.tar.bz2
Fixed asserts due to H5Pset_est_link_info() values (#4081)
* Fixed asserts due to H5Pset_est_link_info() values If large values for est_num_entries and/or est_name_len were passed to H5Pset_est_link_info(), the library would attempt to create an object header NIL message to reserve enough space to hold the links in compact form (i.e., concatenated), which could exceed allowable object header message size limits and trip asserts in the library. This bug only occurred when using the HDF5 1.8 file format or later and required the product of the two values to be ~64k more than the size of any links written to the group, which would cause the library to write out a too-large NIL spacer message to reserve the space for the unwritten links. The library now inspects the phase change values to see if the dataset is likely to be compact and checks the size to ensure any NIL spacer messages won't be larger than the library allows. Fixes GitHub #1632 * Fix copy-paste comments
Diffstat (limited to 'src/H5Gobj.c')
-rw-r--r--src/H5Gobj.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/H5Gobj.c b/src/H5Gobj.c
index e701922..c5bdfc1 100644
--- a/src/H5Gobj.c
+++ b/src/H5Gobj.c
@@ -218,7 +218,25 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linf
assert(link_size);
/* Compute size of header to use for creation */
- hdr_size = linfo_size + ginfo_size + pline_size + (ginfo->est_num_entries * link_size);
+
+ /* Basic header size */
+ hdr_size = linfo_size + ginfo_size + pline_size;
+
+ /* If this is likely to be a compact group, add space for the link
+ * messages, unless the size of the link messages is greater than
+ * the largest allowable object header message size, since the size
+ * of the link messages is the size of the NIL spacer message that
+ * would have to be written out to reserve enough space to hold the
+ * links if the group were left empty.
+ */
+ bool compact = ginfo->est_num_entries <= ginfo->max_compact;
+ if (compact) {
+
+ size_t size_of_links = ginfo->est_num_entries * link_size;
+
+ if (size_of_links < H5O_MESG_MAX_SIZE)
+ hdr_size += size_of_links;
+ }
} /* end if */
else
hdr_size = (size_t)(4 + 2 * H5F_SIZEOF_ADDR(f));