summaryrefslogtreecommitdiffstats
path: root/src/H5Dchunk.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-07-10 08:22:48 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-07-10 08:22:48 (GMT)
commit8935c921f7e50607cd91c86b2237ac39a9b600af (patch)
treeda0b7139c2145c0167d42338f5481e94a1fac458 /src/H5Dchunk.c
parent46450bd9d02d87469d0c74df17cc76616822b8d4 (diff)
downloadhdf5-8935c921f7e50607cd91c86b2237ac39a9b600af.zip
hdf5-8935c921f7e50607cd91c86b2237ac39a9b600af.tar.gz
hdf5-8935c921f7e50607cd91c86b2237ac39a9b600af.tar.bz2
Fix for HDFFV-10217 infinite loop in H5VM_power2up().
The function H5VM_power2up() returns the next power of 2 for n. When n exceeds 2^63, it overflows and becomes 0 causing the infinite looping. The fix ensures that the function checks for n >= 2^63 and returns 0.
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r--src/H5Dchunk.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index d693466..b7b8b03 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -1019,11 +1019,16 @@ H5D__chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id)
unsigned u; /* Local index value */
for(u = 0; u < dset->shared->ndims; u++) {
+ hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */
+
/* Initial scaled dimension sizes */
rdcc->scaled_dims[u] = dset->shared->curr_dims[u] / dset->shared->layout.u.chunk.dim[u];
+ if( !(scaled_power2up = H5VM_power2up(rdcc->scaled_dims[u])) )
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2")
+
/* Inital 'power2up' values for scaled dimensions */
- rdcc->scaled_power2up[u] = H5VM_power2up(rdcc->scaled_dims[u]);
+ rdcc->scaled_power2up[u] = scaled_power2up;
/* Number of bits required to encode scaled dimension size */
rdcc->scaled_encode_bits[u] = H5VM_log2_gen(rdcc->scaled_power2up[u]);