diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-18 10:18:47 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-18 10:18:47 (GMT) |
commit | 53eb52807100a87f5d9237367cb3005cbef1d726 (patch) | |
tree | 27c0720b572ab19988207bec44a2d806f19ca4e4 /src | |
parent | d38c207c3253094371ab0227dc308fd4b1c32b10 (diff) | |
download | hdf5-53eb52807100a87f5d9237367cb3005cbef1d726.zip hdf5-53eb52807100a87f5d9237367cb3005cbef1d726.tar.gz hdf5-53eb52807100a87f5d9237367cb3005cbef1d726.tar.bz2 |
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FDfamily.c | 14 | ||||
-rw-r--r-- | src/H5Gnode.c | 2 | ||||
-rw-r--r-- | src/H5Gstab.c | 4 | ||||
-rw-r--r-- | src/H5Tcommit.c | 2 |
4 files changed, 12 insertions, 10 deletions
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index bd09ea4..5fd0294 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -628,7 +628,7 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out* FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_family_sb_encode) /* Name and version number */ - HDstrncpy(name, "NCSAfami", (size_t)8); + HDstrncpy(name, "NCSAfami", (size_t)9); name[8] = '\0'; /* Store member file size. Use the member file size from the property here. @@ -690,9 +690,9 @@ H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned cha /* Check if member size from file access property is correct */ if(msize != file->pmem_size) { - char err_msg[128]; + char err_msg[128]; - sprintf(err_msg, "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); + HDsnprintf(err_msg, sizeof(err_msg), "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg) } /* end if */ @@ -806,14 +806,14 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, file->flags = flags; /* Check that names are unique */ - sprintf(memb_name, name, 0); - sprintf(temp, name, 1); + HDsnprintf(memb_name, sizeof(memb_name), name, 0); + HDsnprintf(temp, sizeof(temp), name, 1); if(!HDstrcmp(memb_name, temp)) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") /* Open all the family members */ while(1) { - sprintf(memb_name, name, file->nmembs); + HDsnprintf(memb_name, sizeof(memb_name), name, file->nmembs); /* Enlarge member array */ if(file->nmembs >= file->amembs) { @@ -1094,7 +1094,7 @@ H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) /* Create another file if necessary */ if(u >= file->nmembs || !file->memb[u]) { file->nmembs = MAX(file->nmembs, u+1); - sprintf(memb_name, file->name, u); + HDsnprintf(memb_name, sizeof(memb_name), file->name, u); H5E_BEGIN_TRY { H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 5a2d736..5f32eb5 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1239,7 +1239,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, H5O_link_t lnk; /* Link to insert */ const char *name; /* Name of source object */ H5G_entry_t tmp_src_ent; /* Temperary copy. Change will not affect the cache */ - H5O_type_t obj_type; /* Target object type */ + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Target object type */ H5G_copy_file_ud_t *cpy_udata; /* Copy file udata */ H5G_obj_create_t gcrt_info; /* Group creation info */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 7d0ad48..afa137c 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -711,6 +711,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /* Info about local heap & B-tree */ H5G_bt_it_gnbi_t udata; /* Iteration information */ + hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_get_name_by_idx, FAIL) @@ -744,6 +745,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, udata.common.op = H5G_stab_get_name_by_idx_cb; udata.heap = heap; udata.name = NULL; + udata_valid = TRUE; /* Iterate over the group members */ if(H5B_iterate(oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr, H5G_node_by_idx, &udata) < 0) @@ -769,7 +771,7 @@ done: HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Free the duplicated name */ - if(udata.name != NULL) + if(udata_valid && udata.name != NULL) H5MM_xfree(udata.name); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index e109f95..d3779e5 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -221,7 +221,7 @@ done: /* If the datatype was committed but something failed after that, we need * to return it to the state it was in before it was committed. */ - if(ret_value < 0 && ocrt_info.new_obj) { + if(ret_value < 0 && (NULL != ocrt_info.new_obj)) { if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Remove the datatype from the list of opened objects in the file */ if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) |