From 78af4c21cb717d400141d5ed15505e8257497ec9 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 14 Nov 2018 14:31:37 -0600 Subject: HDFFV-10571 Divided by Zero vulnerability. Minor fix: I added an error check to make sure the chunk size is not zero. --- src/H5Dchunk.c | 4 ++++ 1 file changed, 4 insertions(+) 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]) -- cgit v0.12