diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-09-03 18:12:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-03 18:12:53 (GMT) |
commit | 90852b28c729e963a7ebf4b21fe216a44ce7ad2b (patch) | |
tree | ecf4e03b91bedd929bef5babeea8b2d9dc004ae3 /src/H5Dchunk.c | |
parent | b1e65333b5c19457c53d5d6e7fd5e9add81e307d (diff) | |
download | hdf5-90852b28c729e963a7ebf4b21fe216a44ce7ad2b.zip hdf5-90852b28c729e963a7ebf4b21fe216a44ce7ad2b.tar.gz hdf5-90852b28c729e963a7ebf4b21fe216a44ce7ad2b.tar.bz2 |
Cherry-pick of CVE fixes from 1.10 (#3490)
* CVE-2016-4332
* CVE-2018-11202
* CVE-2018-11205
* CVE-2018-13866
* CVE-2018-13867
* CVE-2018-13871
* CVE-2018-15671
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r-- | src/H5Dchunk.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index a0f8371..b5e1d5e 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -701,9 +701,12 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize /* Sanity checks */ HDassert(layout); - HDassert(ndims > 0); HDassert(curr_dims); + /* Can happen when corrupt files are parsed */ + if (ndims == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "number of dimensions cannot be zero") + /* Compute the # of chunks in dataset dimensions */ for (u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { /* Round up to the next integer # of chunks, to accommodate partial chunks */ @@ -915,6 +918,7 @@ H5D__chunk_init(H5F_t *f, const H5D_t *const dset, hid_t dapl_id) H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ H5P_genplist_t *dapl; /* Data access property list object pointer */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + hbool_t idx_init = FALSE; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -990,12 +994,21 @@ H5D__chunk_init(H5F_t *f, const H5D_t *const dset, hid_t dapl_id) /* Allocate any indexing structures */ if (sc->ops->init && (sc->ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") + idx_init = TRUE; /* Set the number of chunks in dataset, etc. */ if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set # of chunks for dataset") done: + if (FAIL == ret_value) { + if (rdcc->slot) + rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); + + if (idx_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info"); + } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_init() */ |