summaryrefslogtreecommitdiffstats
path: root/src/H5Dbtree.c
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2018-07-16 04:31:09 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2018-07-16 04:31:09 (GMT)
commitfa5d96dc5efc463015b4455e6ed2b96346b3b12f (patch)
treee53c588e8ca90a1cd508e87c6b4b5656b2b2f3fe /src/H5Dbtree.c
parentec31438afdaf575368938e930eb3af0865a342b3 (diff)
downloadhdf5-fa5d96dc5efc463015b4455e6ed2b96346b3b12f.zip
hdf5-fa5d96dc5efc463015b4455e6ed2b96346b3b12f.tar.gz
hdf5-fa5d96dc5efc463015b4455e6ed2b96346b3b12f.tar.bz2
Fixed division-by-zero issues
Description: Fixed HDFFV-10481 and HDFFV-10477, division by 0. Fixed another occurrence beside what were reported. Also, changed a local variable to avoid an unnecessary cast. Platforms tested: Linux/64 (jelly) Linux/32 (jam) Darwin (osx1010test)
Diffstat (limited to 'src/H5Dbtree.c')
-rw-r--r--src/H5Dbtree.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index c23f089..04f5419 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -666,12 +666,13 @@ done:
static herr_t
H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key)
{
- const H5O_layout_chunk_t *layout; /* Chunk layout description */
- H5D_btree_key_t *key = (H5D_btree_key_t *) _key; /* Pointer to decoded key */
- hsize_t tmp_offset; /* Temporary coordinate offset, from file */
- unsigned u; /* Local index variable */
+ const H5O_layout_chunk_t *layout; /* Chunk layout description */
+ H5D_btree_key_t *key = (H5D_btree_key_t *) _key; /* Pointer to decoded key */
+ hsize_t tmp_offset; /* Temporary coordinate offset, from file */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
/* check args */
HDassert(shared);
@@ -684,16 +685,22 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key
/* decode */
UINT32DECODE(raw, key->nbytes);
UINT32DECODE(raw, key->filter_mask);
- for(u = 0; u < layout->ndims; u++) {
+ for(u = 0; u < layout->ndims; u++)
+ {
+ if (layout->dim[u] == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL,
+ "chunk size must be > 0, dim = %u ", u)
+
/* Retrieve coordinate offset */
- UINT64DECODE(raw, tmp_offset);
+ UINT64DECODE(raw, tmp_offset);
HDassert(0 == (tmp_offset % layout->dim[u]));
/* Convert to a scaled offset */
key->scaled[u] = tmp_offset / layout->dim[u];
} /* end for */
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__btree_decode_key() */