summaryrefslogtreecommitdiffstats
path: root/src/H5Olayout.c
diff options
context:
space:
mode:
authorSongyu Lu <songyulu@hdfgroup.org>2018-11-15 20:57:26 (GMT)
committerSongyu Lu <songyulu@hdfgroup.org>2018-11-15 20:57:26 (GMT)
commitc132cb5565de02fd4e1e2cfe8ea7b89b21f785ac (patch)
treec76708ca8aed48d03dba4e9604083d9662f4f02c /src/H5Olayout.c
parent1d89a55590d106ea4d242402d0cd57a9d1ce5252 (diff)
downloadhdf5-c132cb5565de02fd4e1e2cfe8ea7b89b21f785ac.zip
hdf5-c132cb5565de02fd4e1e2cfe8ea7b89b21f785ac.tar.gz
hdf5-c132cb5565de02fd4e1e2cfe8ea7b89b21f785ac.tar.bz2
HDFFV-10571: Minor change - adding the error check right after decoding of chunk dimension for safeguard.
Diffstat (limited to 'src/H5Olayout.c')
-rw-r--r--src/H5Olayout.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 5f16837..11d5d1c 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -243,9 +243,14 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr));
/* Chunk dimensions */
- for(u = 0; u < mesg->u.chunk.ndims; u++)
+ for(u = 0; u < mesg->u.chunk.ndims; u++) {
UINT32DECODE(p, mesg->u.chunk.dim[u]);
+ /* Just in case that something goes very wrong, such as file corruption. */
+ if(mesg->u.chunk.dim[u] == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "chunk dimension must be positive: mesg->u.chunk.dim[%u] = %u", u, mesg->u.chunk.dim[u])
+ }
+
/* Compute chunk size */
for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++)
mesg->u.chunk.size *= mesg->u.chunk.dim[u];