diff options
author | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2017-07-10 08:22:48 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2017-07-10 08:22:48 (GMT) |
commit | 8935c921f7e50607cd91c86b2237ac39a9b600af (patch) | |
tree | da0b7139c2145c0167d42338f5481e94a1fac458 /src/H5VMprivate.h | |
parent | 46450bd9d02d87469d0c74df17cc76616822b8d4 (diff) | |
download | hdf5-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/H5VMprivate.h')
-rw-r--r-- | src/H5VMprivate.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 4d71b29..decac7e 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -460,7 +460,11 @@ H5VM_power2up(hsize_t n) { hsize_t ret_value = 1; /* Return value */ - while(ret_value < n) + /* Returns 0 when n exceeds 2^63 */ + if(n >= (hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) - 1)) + ret_value = 0; + + while(ret_value && ret_value < n) ret_value <<= 1; return(ret_value); |