diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2010-01-20 21:26:17 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2010-01-20 21:26:17 (GMT) |
commit | 3026e03ffe1a9fbd117a2d03fb7259a5a3e3ce8b (patch) | |
tree | e03f02651a9207201b9509d9d0c692d1ab9e84b0 /tools | |
parent | 9196ccf05901168a1981686f573d7c3d1283d6bd (diff) | |
download | hdf5-3026e03ffe1a9fbd117a2d03fb7259a5a3e3ce8b.zip hdf5-3026e03ffe1a9fbd117a2d03fb7259a5a3e3ce8b.tar.gz hdf5-3026e03ffe1a9fbd117a2d03fb7259a5a3e3ce8b.tar.bz2 |
[svn-r18127] Purpose:
Fix for bug1749: Incorrect code in diff() function for links compare
Also removed duplicated redundant code, which improves performance.
Description:
When comparing file1 to file2 and both files contain same soft-links and/or
external-links, if file2's target object path name is longer than file1's
target object path name, the current code allocates memory buffer
incorrectly, so it could end up buffer overflow or wrong result.
Tested on Jam.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/h5diff.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 7d11f2f..18dd1ed 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -1024,7 +1024,7 @@ hsize_t diff(hid_t file1_id, if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) goto out; - if(H5Lget_info(file1_id, path1, &li2, H5P_DEFAULT) < 0) + if(H5Lget_info(file2_id, path2, &li2, H5P_DEFAULT) < 0) goto out; buf1 = HDmalloc(li1.u.val_size); @@ -1062,7 +1062,7 @@ hsize_t diff(hid_t file1_id, if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) goto out; - if(H5Lget_info(file1_id, path1, &li2, H5P_DEFAULT) < 0) + if(H5Lget_info(file2_id, path2, &li2, H5P_DEFAULT) < 0) goto out; /* Only external links will have a query function registered */ @@ -1085,16 +1085,6 @@ hsize_t diff(hid_t file1_id, /* If the buffers are the same size, compare them */ if(li1.u.val_size == li2.u.val_size) { - if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) { - HDfree(buf1); - HDfree(buf2); - goto out; - } /* end if */ - if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) { - HDfree(buf1); - HDfree(buf2); - goto out; - } /* end if */ ret = HDmemcmp(buf1, buf2, li1.u.val_size); } else |