summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2023-03-29 18:15:11 (GMT)
committerGitHub <noreply@github.com>2023-03-29 18:15:11 (GMT)
commitabdc160a97c78b01580308fe43204a202d3a6951 (patch)
tree92e828b43bc13be1560f531c9d1d964a5a963d39 /src/H5Oattr.c
parentab1af79798985b57401596677f7db8eb186f55a1 (diff)
downloadhdf5-abdc160a97c78b01580308fe43204a202d3a6951.zip
hdf5-abdc160a97c78b01580308fe43204a202d3a6951.tar.gz
hdf5-abdc160a97c78b01580308fe43204a202d3a6951.tar.bz2
Minor cherry-pick merges to 1.12 (#2581)
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r--src/H5Oattr.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index ac643ea..cb06f25 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -221,10 +221,6 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u
else
p += attr->shared->ds_size;
- /* Get the datatype's size */
- if (0 == (dt_size = H5T_get_size(attr->shared->dt)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size")
-
/* Get the datatype & dataspace sizes */
if (0 == (dt_size = H5T_get_size(attr->shared->dt)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size")
@@ -234,6 +230,9 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u
/* Compute the size of the data */
H5_CHECKED_ASSIGN(attr->shared->data_size, size_t, ds_size * (hsize_t)dt_size, hsize_t);
+ /* Check if multiplication has overflown */
+ if ((attr->shared->data_size / dt_size) != ds_size)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds addressable range")
/* Go get the data */
if (attr->shared->data_size) {