diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2018-03-06 00:08:28 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2018-03-06 00:08:28 (GMT) |
commit | b61c93acb3c5d50d379950f6e3de5040c71dd041 (patch) | |
tree | b0681c4b629fb6a44dc3df6d4f7f174ca7cc142d /src | |
parent | 302053f978e38a8d4306a7c1233cdf8fd2ec28dd (diff) | |
parent | bbadec5680c02dfa975801b964179da9b7c06362 (diff) | |
download | hdf5-b61c93acb3c5d50d379950f6e3de5040c71dd041.zip hdf5-b61c93acb3c5d50d379950f6e3de5040c71dd041.tar.gz hdf5-b61c93acb3c5d50d379950f6e3de5040c71dd041.tar.bz2 |
Merge branch 'develop' into hdffv_10355
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/H5Opline.c | 42 | ||||
-rw-r--r-- | src/H5T.c | 5 |
3 files changed, 34 insertions, 15 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aaedfda..bf7fb07 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.2.2) +cmake_minimum_required (VERSION 3.3.2) PROJECT (HDF5_SRC C CXX) #----------------------------------------------------------------------------- diff --git a/src/H5Opline.c b/src/H5Opline.c index 7bc8f19..e59e192 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -141,8 +141,15 @@ H5O_pline_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5 /* Number of filters */ pline->nused = *p++; - if(pline->nused > H5Z_MAX_NFILTERS) + if(pline->nused > H5Z_MAX_NFILTERS) { + + /* Reset the number of filters used to avoid array traversal in error + * handling code. + */ + pline->nused = 0; + HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters") + } /* Reserved */ if(pline->version == H5O_PLINE_VERSION_1) @@ -509,23 +516,30 @@ H5O_pline_reset(void *mesg) FUNC_ENTER_NOAPI_NOINIT_NOERR + /* NOTE: This function can be called during error processing from + * other API calls so DO NOT ASSUME THAT ANY VALUES ARE SANE. + */ + HDassert(pline); - /* Free information for each filter */ - for(i = 0; i < pline->nused; i++) { - if(pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name) - HDassert((HDstrlen(pline->filter[i].name) + 1) > H5Z_COMMON_NAME_LEN); - if(pline->filter[i].name != pline->filter[i]._name) - pline->filter[i].name = (char *)H5MM_xfree(pline->filter[i].name); - if(pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values) - HDassert(pline->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES); - if(pline->filter[i].cd_values != pline->filter[i]._cd_values) - pline->filter[i].cd_values = (unsigned *)H5MM_xfree(pline->filter[i].cd_values); - } /* end for */ + /* Free the filter information and array */ + if (pline->filter) { + + /* Free information for each filter */ + for(i = 0; i < pline->nused; i++) { + if(pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name) + HDassert((HDstrlen(pline->filter[i].name) + 1) > H5Z_COMMON_NAME_LEN); + if(pline->filter[i].name != pline->filter[i]._name) + pline->filter[i].name = (char *)H5MM_xfree(pline->filter[i].name); + if(pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values) + HDassert(pline->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES); + if(pline->filter[i].cd_values != pline->filter[i]._cd_values) + pline->filter[i].cd_values = (unsigned *)H5MM_xfree(pline->filter[i].cd_values); + } /* end for */ - /* Free filter array */ - if(pline->filter) + /* Free filter array */ pline->filter = (H5Z_filter_info_t *)H5MM_xfree(pline->filter); + } /* Reset # of filters */ pline->nused = pline->nalloc = 0; @@ -5216,6 +5216,11 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Check if the field changed size */ if(old_size != memb_type->shared->size) { + + /* Fail if the old_size is zero */ + if (0 == old_size) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero"); + /* Adjust the size of the member */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; |