diff options
author | Mike McGreevy <mamcgree@hdfgroup.org> | 2010-11-17 15:08:53 (GMT) |
---|---|---|
committer | Mike McGreevy <mamcgree@hdfgroup.org> | 2010-11-17 15:08:53 (GMT) |
commit | f396947f6466d6a58796bf3a5147acf1ccb8bad8 (patch) | |
tree | 60970c82d9e1fbf3dc17f81352b7369e9b1156fe /test/links.c | |
parent | 10c3eb0a9fc87e6005c4dffb3dd078c37f584d26 (diff) | |
download | hdf5-f396947f6466d6a58796bf3a5147acf1ccb8bad8.zip hdf5-f396947f6466d6a58796bf3a5147acf1ccb8bad8.tar.gz hdf5-f396947f6466d6a58796bf3a5147acf1ccb8bad8.tar.bz2 |
[svn-r19800] Purpose:
Add additional error checking to catch erroneous user input.
Description:
Attempting to retrieve a links's name by index in the case
where the link is external and the file that the object is
located in doesn't exist was causing a segmentation fault
(in production) and an assertion failure (in debug).
The segfault wasn't occuring until the metadata accumulator
attempted a write, so I've added error checking higher in
the pipeline in H5O_protect (where there was previously just
an assert) to catch this. I've also added additional asserts
in the H5F layer where there were none.
Additionally, I added another case to the links.c test to
test that this fails gracefully instead of segfaulting or
asserting out.
Tested:
h5committest and gandalf (mac os x)
Diffstat (limited to 'test/links.c')
-rw-r--r-- | test/links.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/links.c b/test/links.c index 8e24515..650f9e8 100644 --- a/test/links.c +++ b/test/links.c @@ -2640,6 +2640,8 @@ external_link_dangling(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group IDs */ + hid_t rid = (-1); /* Root Group ID */ + hid_t status = (-1); /* Status */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ @@ -2672,6 +2674,9 @@ external_link_dangling(hid_t fapl, hbool_t new_format) /* Open first file */ if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Get root group ID */ + if((rid=H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR; + /* Open object through dangling file external link */ H5E_BEGIN_TRY { gid = H5Gopen2(fid, "no_file", H5P_DEFAULT); @@ -2692,6 +2697,18 @@ external_link_dangling(hid_t fapl, hbool_t new_format) goto error; } + /* Try to get name of object by index through dangling file external link */ + H5E_BEGIN_TRY { + status = H5Lget_name_by_idx(rid, "no_file", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, 0, H5P_DEFAULT); + } H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + puts(" Retreiving name of object by index through dangling file external link should have failed."); + } /* end if */ + + /* Close root group */ + if(H5Gclose(rid) < 0) TEST_ERROR + /* Close first file */ if(H5Fclose(fid) < 0) TEST_ERROR |