summaryrefslogtreecommitdiffstats
path: root/Tests/CheckFortran.cmake
Commit message (Expand)AuthorAgeFilesLines
* Tests: Avoid hanging on check for FortranBrad King2017-11-061-0/+1
* Tests: Pass generator instance into check for FortranBrad King2017-11-061-0/+6
* Tests: Pass generator platform and toolset into check for FortranBrad King2017-03-081-0/+2
* Simplify CMake per-source license noticesBrad King2016-09-271-12/+2
* Tests: Check if Fortran compiler supports F90Brad King2016-09-221-0/+3
* Modules: Fix spelling 'To distributed' -> 'To distribute'Todd Gamblin2010-08-091-1/+1
* Honor real language flags in FortranC.Flags testBrad King2009-12-151-1/+6
* New decision method to enable Fortran testsBrad King2009-12-101-0/+45
C - (*parms_index)++; /* skip total size of compound datatype */ + size = parms[(*parms_index)++]; nmembers = parms[(*parms_index)++]; for(i = 0; i < nmembers; i++) { member_offset = parms[(*parms_index)++]; member_class = parms[(*parms_index)++]; + + /* Check for overflow */ + member_size = parms[*parms_index]; + used_size += member_size; + if(used_size > size) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") switch(member_class) { case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; + p.size = member_size; + /* Advance past member size */ + (*parms_index)++; p.order = parms[(*parms_index)++]; p.precision = parms[(*parms_index)++]; p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + H5Z_nbit_decompress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); break; case H5Z_NBIT_ARRAY: - H5Z_nbit_decompress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_array(data, data_offset + member_offset, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") break; case H5Z_NBIT_COMPOUND: - H5Z_nbit_decompress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_compound(data, data_offset+member_offset, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") break; case H5Z_NBIT_NOOPTYPE: - size = parms[(*parms_index)++]; + /* Advance past member size */ + (*parms_index)++; H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset, buffer, j, buf_len, size); break; @@ -1265,10 +1298,13 @@ H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, HDassert(0 && "This Should never be executed!"); } /* end switch */ } + +done: + FUNC_LEAVE_NOAPI(ret_value) } -static void -H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, +static herr_t +H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]) { /* i: index of data, j: index of buffer, @@ -1278,6 +1314,9 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size_t buf_len; parms_atomic p; unsigned parms_index; /* index in array parms used by compression/decompression functions */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC /* may not have to initialize to zeros */ HDmemset(data, 0, d_nelmts * parms[4]); @@ -1292,6 +1331,11 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe p.order = parms[5]; p.precision = parms[6]; p.offset = parms[7]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + for(i = 0; i < d_nelmts; i++) H5Z_nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); break; @@ -1300,7 +1344,8 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size = parms[4]; parms_index = 4; /* set the index before goto function call */ for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index); + if(H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") parms_index = 4; } break; @@ -1309,7 +1354,8 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size = parms[4]; parms_index = 4; /* set the index before goto function call */ for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index); + if(H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") parms_index = 4; } break; @@ -1317,6 +1363,9 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe default: HDassert(0 && "This Should never be executed!"); } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) } static void -- cgit v0.12 From bc10fd219e60fc4b9df7d80567ecb1e39ae5b6e3 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 8 Sep 2016 13:47:22 -0500 Subject: Change check for number of dimensions for old-style arrays in datatype decoding routine from an assertion to an if/HGOTO_ERROR check, since it is inappropriate to assert the contents of a file will be what we expect. --- src/H5Odtype.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index e51d319..3c3f284 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -311,7 +311,11 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p if(version == H5O_DTYPE_VERSION_1) { /* Decode the number of dimensions */ ndims = *(*pp)++; - HDassert(ndims <= 4); + + /* Check that ndims is valid */ + if(ndims > 4) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") + *pp += 3; /*reserved bytes */ /* Skip dimension permutation */ -- cgit v0.12 From 391a231b76c1200ecda5d74636213e9e479fa51a Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 9 Sep 2016 12:08:30 -0500 Subject: Fix bug in "nooptype" decode in fix for TALOS-0177. --- src/H5Znbit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 7efab42..7a41d16 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -1291,7 +1291,7 @@ H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, /* Advance past member size */ (*parms_index)++; H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, size); + buffer, j, buf_len, member_size); break; default: -- cgit v0.12 From ef2e93d23988b44c663b6df583edecd2e604f009 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 19 Sep 2016 14:04:40 -0500 Subject: Eliminate unreferenced local variable warning --- java/src/jni/h5pImp.c | 12 ------------ java/src/jni/h5util.c | 18 +----------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index ad79733..7c71da1 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -4947,7 +4947,6 @@ H5P_cls_create_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); @@ -4972,7 +4971,6 @@ H5P_cls_copy_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); @@ -4995,7 +4993,6 @@ H5P_cls_close_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); @@ -5019,7 +5016,6 @@ H5D_append_cb jclass cls; jmethodID mid; jlongArray cur_dimsArray; - jsize size; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { JVMPTR->DetachCurrentThread(JVMPAR); @@ -5135,7 +5131,6 @@ H5P_prp_create_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5160,7 +5155,6 @@ H5P_prp_copy_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5185,7 +5179,6 @@ H5P_prp_close_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5210,7 +5203,6 @@ H5P_prp_compare_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR compare_callback); @@ -5233,7 +5225,6 @@ H5P_prp_get_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5258,7 +5249,6 @@ H5P_prp_set_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5283,7 +5273,6 @@ H5P_prp_delete_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5472,7 +5461,6 @@ H5P_iterate_cb jclass cls; jmethodID mid; jstring str; - jmethodID constructor; /* fprintf(stderr, "\nJNI H5P_iterate_cb entered\n"); fflush(stderr); */ if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index acf57c8..0d2999a 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -181,7 +181,6 @@ h5str_sprintf char *this_str; size_t this_strlen; int n; - int len; hvl_t *vlptr; char *cptr = (char*) ptr; unsigned char *ucptr = (unsigned char*) ptr; @@ -522,7 +521,6 @@ h5str_print_region_data_blocks hsize_t *count = NULL; hsize_t blkndx; hsize_t total_size[H5S_MAX_RANK]; - unsigned int region_flags; /* buffer extent flags */ hsize_t numelem; hsize_t numindex; size_t jndx; @@ -622,7 +620,6 @@ h5str_dump_region_blocks_data hsize_t *ptdata; hid_t dtype = -1; hid_t type_id = -1; - char tmp_str[256]; int ndims = H5Sget_simple_extent_ndims(region); /* @@ -634,8 +631,6 @@ h5str_dump_region_blocks_data /* Print block information */ if (nblocks > 0) { - int i; - alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); @@ -745,13 +740,10 @@ h5str_print_region_data_points hsize_t *dims1 = NULL; hsize_t total_size[H5S_MAX_RANK]; size_t jndx; - unsigned indx; size_t type_size; int ret_value = SUCCEED; - unsigned int region_flags; /* buffer extent flags */ hid_t mem_space = -1; void *region_buf = NULL; - char tmp_str[256]; /* Allocate space for the dimension array */ if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { @@ -810,7 +802,6 @@ h5str_dump_re