diff options
author | Songyu Lu <songyulu@barracuda.ad.hdfgroup.org> | 2018-11-14 20:31:37 (GMT) |
---|---|---|
committer | Songyu Lu <songyulu@barracuda.ad.hdfgroup.org> | 2018-11-14 20:31:37 (GMT) |
commit | 78af4c21cb717d400141d5ed15505e8257497ec9 (patch) | |
tree | 08d6f49710195d39f24f045edae515bce086433f /src | |
parent | ca1788e0823b6915eec785de3a880987eae54a2a (diff) | |
download | hdf5-78af4c21cb717d400141d5ed15505e8257497ec9.zip hdf5-78af4c21cb717d400141d5ed15505e8257497ec9.tar.gz hdf5-78af4c21cb717d400141d5ed15505e8257497ec9.tar.bz2 |
HDFFV-10571 Divided by Zero vulnerability. Minor fix: I added an error check to make sure the chunk size is not zero.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dchunk.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 22dc05a..fabae54 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -695,6 +695,10 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, /* Compute the # of chunks in dataset dimensions */ for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { + /* Just in case that something goes very wrong, such as file corruption. */ + if(layout->dim[u] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be positive: layout->dim[%u] = %u ", u, layout->dim[u]) + /* Round up to the next integer # of chunks, to accommodate partial chunks */ layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; if(H5S_UNLIMITED == max_dims[u]) |