diff options
-rw-r--r-- | hl/src/H5DS.c | 65 | ||||
-rw-r--r-- | hl/src/H5IM.c | 129 | ||||
-rw-r--r-- | hl/src/H5LT.c | 84 | ||||
-rw-r--r-- | hl/src/H5PT.c | 15 | ||||
-rw-r--r-- | hl/src/H5TB.c | 105 |
5 files changed, 370 insertions, 28 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 15d2f21..66684d6 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1444,6 +1444,9 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) if (H5I_DATASET != it) return FAIL; + if (label == NULL) + return FAIL; + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1912,11 +1915,12 @@ out: htri_t H5DSis_scale(hid_t did) { hid_t tid = -1; /* attribute type ID */ - hid_t aid; /* attribute ID */ + hid_t aid = -1; /* attribute ID */ herr_t has_class; /* has the "CLASS" attribute */ htri_t is_ds; /* boolean return value */ H5I_type_t it; /* ID type */ - char buf[20]; + char *buf; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ /*------------------------------------------------------------------------- * parameter checking @@ -1944,19 +1948,41 @@ htri_t H5DSis_scale(hid_t did) if((tid = H5Aget_type(aid)) < 0) goto out; + /* check to make sure attribute is a string */ + if(H5T_STRING != H5Tget_class(tid)) + goto out; + + /* check to make sure string is null-terminated */ + if(H5T_STR_NULLTERM != H5Tget_strpad(tid)) + goto out; + + /* allocate buffer large enough to hold string */ + if((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; + + buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); + if(buf == NULL) + goto out; + + /* Read the attribute */ if(H5Aread(aid, tid, buf) < 0) - goto out; + goto out; - if(strcmp(buf, DIMENSION_SCALE_CLASS)==0) + /* compare strings */ + if(HDstrncmp(buf, DIMENSION_SCALE_CLASS, MIN(HDstrlen(DIMENSION_SCALE_CLASS),HDstrlen(buf)))==0) is_ds = 1; else is_ds = 0; + HDfree(buf); + if(H5Tclose(tid) < 0) goto out; if (H5Aclose(aid) < 0) goto out; + + } return is_ds; @@ -2118,7 +2144,8 @@ herr_t H5DS_is_reserved(hid_t did) int has_class; hid_t tid = -1; hid_t aid = -1; - char buf[40]; + char *buf; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ herr_t ret; /* try to find the attribute "CLASS" on the dataset */ @@ -2135,16 +2162,36 @@ herr_t H5DS_is_reserved(hid_t did) if((tid = H5Aget_type(aid)) < 0) goto out; + /* check to make sure attribute is a string */ + if(H5T_STRING != H5Tget_class(tid)) + goto out; + + /* check to make sure string is null-terminated */ + if(H5T_STR_NULLTERM != H5Tget_strpad(tid)) + goto out; + + /* allocate buffer large enough to hold string */ + if((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; + + buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); + if(buf == NULL) + goto out; + + /* Read the attribute */ if(H5Aread(aid, tid, buf) < 0) - goto out; + goto out; + - if(strcmp(buf, IMAGE_CLASS) == 0 || - strcmp(buf, PALETTE_CLASS) == 0 || - strcmp(buf, TABLE_CLASS) == 0 ) + if(HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(buf))) == 0 || + HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(buf))) == 0 || + HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS),HDstrlen(buf))) == 0 ) ret = 1; else ret = 0; + HDfree(buf); + if (H5Tclose(tid) < 0) goto out; diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 9239e4e..aeda6ab 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -46,6 +46,10 @@ herr_t H5IMmake_image_8bit( hid_t loc_id, { hsize_t dims[IMAGE8_RANK]; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Initialize the image dimensions */ dims[0] = height; dims[1] = width; @@ -103,9 +107,16 @@ herr_t H5IMmake_image_24bit( hid_t loc_id, { hsize_t dims[IMAGE24_RANK]; + /* check the arguments */ + if (interlace == NULL) + return -1; + if (dset_name == NULL) + return -1; + + /* Initialize the image dimensions */ - if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) + if ( HDstrncmp( interlace, "INTERLACE_PIXEL",15 ) == 0 ) { /* Number of color planes is defined as the third dimension */ dims[0] = height; @@ -113,7 +124,7 @@ herr_t H5IMmake_image_24bit( hid_t loc_id, dims[2] = IMAGE24_RANK; } else - if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) + if ( HDstrncmp( interlace, "INTERLACE_PLANE",15 ) == 0 ) { /* Number of color planes is defined as the first dimension */ dims[0] = IMAGE24_RANK; @@ -172,6 +183,10 @@ static herr_t find_palette(hid_t loc_id, { int ret = H5_ITER_CONT; + /* check the arguments */ + if (name == NULL) + return -1; + /* Shut compiler up */ loc_id = loc_id; ainfo = ainfo; op_data = op_data; @@ -179,7 +194,7 @@ static herr_t find_palette(hid_t loc_id, * cause the iterator to immediately return that positive value, * indicating short-circuit success */ - if(strcmp(name, "PALETTE") == 0) + if(HDstrncmp(name, "PALETTE",7) == 0) ret = H5_ITER_STOP; return ret; @@ -250,6 +265,12 @@ herr_t H5IMget_image_info( hid_t loc_id, int has_pal; int has_attr; + /* check the arguments */ + if (dset_name == NULL) + return -1; + if (interlace == NULL) + return -1; + /*assume initially we have no palettes attached*/ *npals = 0; @@ -294,7 +315,7 @@ herr_t H5IMget_image_info( hid_t loc_id, /* This is a 24 bit image */ { - if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) + if ( HDstrncmp( interlace, "INTERLACE_PIXEL", 15 ) == 0 ) { /* Number of color planes is defined as the third dimension */ *height = dims[0]; @@ -302,14 +323,14 @@ herr_t H5IMget_image_info( hid_t loc_id, *planes = dims[2]; } else - if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) + if ( HDstrncmp( interlace, "INTERLACE_PLANE", 15 ) == 0 ) { /* Number of color planes is defined as the first dimension */ *planes = dims[0]; *height = dims[1]; *width = dims[2]; } - else return -1; + else return -1; } else /* This is a 8 bit image */ @@ -410,6 +431,10 @@ herr_t H5IMread_image( hid_t loc_id, { hid_t did; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; @@ -460,6 +485,10 @@ herr_t H5IMmake_palette( hid_t loc_id, int has_pal; + /* check the arguments */ + if (pal_name == NULL) + return -1; + /* Check if the dataset already exists */ has_pal = H5LTfind_dataset( loc_id, pal_name ); @@ -523,6 +552,13 @@ herr_t H5IMlink_palette( hid_t loc_id, hsize_t dim_ref; int ok_pal; + + /* check the arguments */ + if (image_name == NULL) + return -1; + if (pal_name == NULL) + return -1; + /* The image dataset may or may not have the attribute "PALETTE" * First we try to open to see if it is already there; if not, it is created. * If it exists, the array of references is extended to hold the reference @@ -685,6 +721,12 @@ herr_t H5IMunlink_palette( hid_t loc_id, H5T_class_t aclass; int ok_pal, has_pal; + /* check the arguments */ + if(image_name == NULL) + return -1; + if(pal_name == NULL) + return -1; + /* Try to find the palette dataset */ has_pal = H5LTfind_dataset( loc_id, pal_name ); @@ -780,6 +822,10 @@ herr_t H5IMget_npalettes( hid_t loc_id, H5T_class_t aclass; int has_pal; + /* check the arguments */ + if(image_name == NULL) + return -1; + /*assume initially we have no palettes attached*/ *npals = 0; @@ -875,6 +921,10 @@ herr_t H5IMget_palette_info( hid_t loc_id, hid_t pal_space_id; hsize_t pal_maxdims[2]; + /* check the arguments */ + if (image_name == NULL) + return -1; + /* Open the dataset. */ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; @@ -986,6 +1036,13 @@ herr_t H5IMget_palette( hid_t loc_id, hobj_ref_t *refbuf; /* buffer to read references */ hid_t pal_id; + /* check the arguments */ + if (image_name == NULL) + return -1; + if (pal_data == NULL) + return -1; + + /* Open the dataset. */ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; @@ -1078,10 +1135,15 @@ herr_t H5IMis_image( hid_t loc_id, hid_t did; int has_class; hid_t atid; - hid_t aid; - char attr_data[20]; + hid_t aid = -1; + char* attr_data; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ herr_t ret; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Assume initially fail condition */ ret = -1; @@ -1106,17 +1168,32 @@ herr_t H5IMis_image( hid_t loc_id, if((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) - goto out; + /* check to make sure attribute is a string */ + if(H5T_STRING != H5Tget_class(atid)) + goto out; + + /* check to make sure string is null-terminated */ + if(H5T_STR_NULLTERM != H5Tget_strpad(atid)) + goto out; + + /* allocate buffer large enough to hold string */ + if((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; + + attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); + if(attr_data == NULL) + goto out; if(H5Aread(aid, atid, attr_data) < 0) goto out; - if(strcmp(attr_data, IMAGE_CLASS) == 0) + if(HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(attr_data))) == 0) ret = 1; else ret = 0; + HDfree(attr_data); + if ( H5Tclose( atid ) < 0) goto out; @@ -1163,10 +1240,15 @@ herr_t H5IMis_palette( hid_t loc_id, hid_t did; int has_class; hid_t atid; - hid_t aid; - char attr_data[20]; + hid_t aid = -1; + char* attr_data; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ herr_t ret; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Assume initially fail condition */ ret = -1; @@ -1191,17 +1273,32 @@ herr_t H5IMis_palette( hid_t loc_id, if((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) - goto out; + /* check to make sure attribute is a string */ + if(H5T_STRING != H5Tget_class(atid)) + goto out; + + /* check to make sure string is null-terminated */ + if(H5T_STR_NULLTERM != H5Tget_strpad(atid)) + goto out; + + /* allocate buffer large enough to hold string */ + if((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; + + attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); + if(attr_data == NULL) + goto out; if(H5Aread(aid, atid, attr_data) < 0) goto out; - if(strcmp(attr_data, PALETTE_CLASS) == 0) + if(HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(attr_data))) == 0) ret = 1; else ret = 0; + HDfree(attr_data); + if ( H5Tclose( atid ) < 0) goto out; diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 6003c60..1eba40c 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -523,6 +523,10 @@ H5LT_make_dataset_numerical( hid_t loc_id, { hid_t did = -1, sid = -1; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Create the data space for the dataset. */ if((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; @@ -798,6 +802,10 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, hid_t tid = -1; size_t size; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* create a string data type */ if((tid = H5Tcopy(H5T_C_S1)) < 0 ) goto out; @@ -976,6 +984,10 @@ H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void { hid_t did; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; @@ -1167,6 +1179,10 @@ herr_t H5LTread_dataset_string( hid_t loc_id, hid_t did = -1; hid_t tid = -1; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; @@ -1216,6 +1232,10 @@ herr_t H5LTget_dataset_ndims( hid_t loc_id, hid_t did = -1; hid_t sid = -1; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* Open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; @@ -1272,6 +1292,10 @@ herr_t H5LTget_dataset_info( hid_t loc_id, hid_t tid = -1; hid_t sid = -1; + /* check the arguments */ + if (dset_name == NULL) + return -1; + /* open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; @@ -1345,6 +1369,10 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d */ int ret = 0; + /* check the arguments */ + if (name == NULL) + return ret; + /* Shut the compiler up */ loc_id = loc_id; linfo = linfo; @@ -1353,7 +1381,7 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d * cause the iterator to immediately return that positive value, * indicating short-circuit success */ - if(HDstrcmp(name, (char *)op_data) == 0) + if(HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) ret = 1; return ret; @@ -1428,6 +1456,14 @@ herr_t H5LTset_attribute_string( hid_t loc_id, int has_attr; size_t attr_size; + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + if (attr_data == NULL) + return -1; + /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; @@ -1517,6 +1553,12 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id, hsize_t dim_size=size; int has_attr; + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; @@ -1928,6 +1970,10 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, { int ret = H5_ITER_CONT; + /* check the arguments */ + if (name == NULL) + return H5_ITER_CONT; + /* Shut compiler up */ loc_id = loc_id; ainfo = ainfo; @@ -1935,7 +1981,7 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, * cause the iterator to immediately return that positive value, * indicating short-circuit success */ - if(HDstrcmp(name, (char *)op_data) == 0) + if(HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) ret = H5_ITER_STOP; return ret; @@ -2020,6 +2066,12 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id, hid_t sid; hid_t obj_id; + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + /* Open the object */ if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; @@ -2087,6 +2139,12 @@ herr_t H5LTget_attribute_info( hid_t loc_id, hid_t sid; hid_t obj_id; + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + /* Open the object */ if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; @@ -2162,6 +2220,10 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) { hid_t type_id; + /* check the arguments */ + if (text == NULL) + return -1; + if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; @@ -3019,6 +3081,12 @@ herr_t H5LTget_attribute_string( hid_t loc_id, /* identifiers */ hid_t obj_id; + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + /* Open the object */ if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; @@ -3439,6 +3507,12 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, hid_t obj_id = -1; hid_t attr_id = -1; + /* check the arguments */ + if (obj_name == NULL) + return -1; + if (attr_name == NULL) + return -1; + /* Open the object */ if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) goto out; @@ -3618,6 +3692,12 @@ H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) /* Initialize */ ret_value = FALSE; + /* check the arguments */ + if (path == NULL) { + ret_value = FAIL; + goto done; + } + /* Find the type of loc_id */ if((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { ret_value = FAIL; diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index d3a03cd..7a0bc20 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -84,6 +84,11 @@ hid_t H5PTcreate_fl ( hid_t loc_id, hsize_t maxdims[1]; hid_t ret_value; + /* check the arguments */ + if (dset_name == NULL) { + goto out; + } + /* Register the packet table ID type if this is the first table created */ if(H5PT_ptable_id_type < 0) if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) @@ -178,6 +183,11 @@ hid_t H5PTcreate_vl ( hid_t loc_id, hid_t ret_value=H5I_BADID; hid_t vltype; + /* check the arguments */ + if (dset_name == NULL) { + goto out; + } + /* Create a variable length type that uses single bytes as its base type */ vltype = H5Tvlen_create(H5T_NATIVE_UCHAR); if(vltype < 0) @@ -232,6 +242,11 @@ hid_t H5PTopen( hid_t loc_id, hid_t ret_value; hsize_t dims[1]; + /* check the arguments */ + if (dset_name == NULL) { + goto out; + } + /* Register the packet table ID type if this is the first table created */ if( H5PT_ptable_id_type < 0) if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index a1456ea..7856d5f 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -94,6 +94,17 @@ herr_t H5TBmake_table(const char *table_title, hsize_t i; herr_t ret_val = -1; + /* check the arguments */ + if (table_title == NULL) { + goto out; + } + if (dset_name == NULL) { + goto out; + } + if (field_names == NULL) { + goto out; + } + dims[0] = nrecords; dims_chunk[0] = chunk_size; @@ -290,6 +301,10 @@ herr_t H5TBappend_records(hid_t loc_id, hsize_t nfields; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* get the original number of records and fields */ if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) goto out; @@ -360,6 +375,10 @@ herr_t H5TBwrite_records(hid_t loc_id, hsize_t dims[1]; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; @@ -459,6 +478,12 @@ herr_t H5TBwrite_fields_name(hid_t loc_id, size_t size_native; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + if (field_names == NULL) + goto out; + /* create xfer properties to preserve initialized data */ if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; @@ -616,6 +641,10 @@ herr_t H5TBwrite_fields_index(hid_t loc_id, char *member_name = NULL; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* create xfer properties to preserve initialized data */ if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; @@ -773,6 +802,10 @@ herr_t H5TBread_table(hid_t loc_id, hsize_t dims[1]; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; @@ -846,6 +879,10 @@ herr_t H5TBread_records(hid_t loc_id, hsize_t nfields; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* get the number of records and fields */ if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) goto out; @@ -922,6 +959,13 @@ herr_t H5TBread_fields_name(hid_t loc_id, hssize_t i, j; herr_t ret_val = -1; + + /* check the arguments */ + if (dset_name == NULL) + goto out; + if (field_names == NULL) + goto out; + /* open the dataset */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; @@ -1074,6 +1118,10 @@ herr_t H5TBread_fields_index(hid_t loc_id, char *member_name = NULL; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; @@ -1231,6 +1279,11 @@ herr_t H5TBdelete_record(hid_t loc_id, unsigned char *tmp_buf = NULL; herr_t ret_val = -1; + + /* check the arguments */ + if (dset_name == NULL) + goto out; + /*------------------------------------------------------------------------- * first we get information about type size and offsets on disk *------------------------------------------------------------------------- @@ -1390,6 +1443,10 @@ herr_t H5TBinsert_record(hid_t loc_id, unsigned char *tmp_buf = NULL; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /*------------------------------------------------------------------------- * read the records after the inserted one(s) *------------------------------------------------------------------------- @@ -1541,6 +1598,12 @@ herr_t H5TBadd_records_from(hid_t loc_id, unsigned char *tmp_buf = NULL; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name1 == NULL) + goto out; + if (dset_name2 == NULL) + goto out; + /*------------------------------------------------------------------------- * first we get information about type size and offsets on disk *------------------------------------------------------------------------- @@ -1688,6 +1751,14 @@ herr_t H5TBcombine_tables(hid_t loc_id1, htri_t has_fill; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name1 == NULL) + goto out; + if (dset_name2 == NULL) + goto out; + if (dset_name3 == NULL) + goto out; + /*------------------------------------------------------------------------- * first we get information about type size and offsets on disk *------------------------------------------------------------------------- @@ -2043,6 +2114,12 @@ herr_t H5TBinsert_field(hid_t loc_id, hbool_t inserted; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + if (field_name == NULL) + goto out; + /* get the number of records and fields */ if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; @@ -2451,6 +2528,13 @@ herr_t H5TBdelete_field(hid_t loc_id, htri_t has_fill = FALSE; herr_t ret_val = -1; + + /* check the arguments */ + if (dset_name == NULL) + goto out; + if (field_name == NULL) + goto out; + /* get the number of records and fields */ if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; @@ -2859,6 +2943,7 @@ out: herr_t H5TBAget_title(hid_t loc_id, char *table_title) { + /* Get the TITLE attribute */ if(H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0) return -1; @@ -2894,6 +2979,10 @@ htri_t H5TBAget_fill(hid_t loc_id, htri_t has_fill = FALSE; htri_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* get the number of records and fields */ if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; @@ -2962,6 +3051,10 @@ herr_t H5TBget_table_info(hid_t loc_id, int num_members; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; @@ -3049,6 +3142,10 @@ herr_t H5TBget_field_info(hid_t loc_id, hssize_t i; herr_t ret_val = -1; + /* check the arguments */ + if (dset_name == NULL) + goto out; + /* open the dataset. */ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; @@ -3153,6 +3250,12 @@ hbool_t H5TB_find_field(const char *field, const char *field_list) const char *start = field_list; const char *end; + /* check the arguments */ + if (field == NULL) + return FALSE; + if (field_list == NULL) + return FALSE; + while((end = HDstrstr(start, ",")) != 0) { ptrdiff_t count = end - start; @@ -3161,7 +3264,7 @@ hbool_t H5TB_find_field(const char *field, const char *field_list) start = end + 1; } /* end while */ - if(HDstrcmp(start, field) == 0) + if(HDstrncmp(start, field, HDstrlen(field)) == 0) return TRUE; return FALSE; |