diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-10 13:58:14 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-10 13:58:14 (GMT) |
commit | 57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b (patch) | |
tree | 380ac2bbfb34b1c1444f5a59c48acdf09996bc87 /tools/h5import/h5import.c | |
parent | 892050a830bd87e32b9a64e388654bc1a9af4cf1 (diff) | |
download | hdf5-57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b.zip hdf5-57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b.tar.gz hdf5-57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b.tar.bz2 |
[svn-r17982] Description:
Bring r17980 from trunk to 1.8 branch:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
(h5committested on trunk)
Diffstat (limited to 'tools/h5import/h5import.c')
-rwxr-xr-x | tools/h5import/h5import.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index 3818829..60ef494 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -1587,16 +1587,29 @@ static int parsePathInfo(struct path_info *path, char *temp) { const char delimiter[] = "/"; - char *token = (char*) malloc(255*sizeof(char)); + char *token; int i=0; + const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n"; + + token = HDstrtok (temp, delimiter); + if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) + { + (void) fprintf(stderr, err1); + return (-1); + } + HDstrcpy(path->group[i++],token); - HDstrcpy(path->group[i++],HDstrtok (temp, delimiter)); while (1) { token = HDstrtok (NULL, delimiter); if (token == NULL) break; + if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) + { + (void) fprintf(stderr, err1); + return (-1); + } HDstrcpy(path->group[i++],token); } path->count = i; @@ -1608,11 +1621,12 @@ parseDimensions(struct Input *in, char *strm) { const char delimiter[] = ","; char temp[255]; - char *token = (char*) malloc(255*sizeof(char)); + char *token; int i=0; const char *err1 = "Unable to allocate dynamic memory.\n"; - HDstrcpy(temp, strm); + HDstrncpy(temp, strm, sizeof(temp)); + temp[sizeof(temp)-1] = '\0'; HDstrtok (temp, delimiter); while (1) @@ -1631,7 +1645,8 @@ parseDimensions(struct Input *in, char *strm) } i=0; - HDstrcpy(temp, strm); + HDstrncpy(temp, strm, sizeof(temp)); + temp[sizeof(temp)-1] = '\0'; in->sizeOfDimension[i++] = HDstrtol(HDstrtok (temp, delimiter), NULL, BASE_10); while (1) |