summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-08-23 21:23:09 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-08-23 21:23:09 (GMT)
commit1ef8577a4aaaa4120a819ff36747fdca99abdc26 (patch)
treef360f1e27e145cb82608eb11079c9aff876d0984 /test
parentb07eb6efd06bbe44562fe6c93e826f40a56c01d2 (diff)
downloadhdf5-1ef8577a4aaaa4120a819ff36747fdca99abdc26.zip
hdf5-1ef8577a4aaaa4120a819ff36747fdca99abdc26.tar.gz
hdf5-1ef8577a4aaaa4120a819ff36747fdca99abdc26.tar.bz2
Modifications based on comments from pull request review
(1) Remove unnecessary asserts (2) Add code to insert bad offset values to the test file in gen_bad_offset.c
Diffstat (limited to 'test')
-rw-r--r--test/bad_offset.h5bin3312 -> 3312 bytes
-rw-r--r--test/gen_bad_offset.c41
-rw-r--r--test/tmisc.c2
3 files changed, 39 insertions, 4 deletions
diff --git a/test/bad_offset.h5 b/test/bad_offset.h5
index 6500ffe..231dca2 100644
--- a/test/bad_offset.h5
+++ b/test/bad_offset.h5
Binary files differ
diff --git a/test/gen_bad_offset.c b/test/gen_bad_offset.c
index 2be4af1..82e94cd 100644
--- a/test/gen_bad_offset.c
+++ b/test/gen_bad_offset.c
@@ -27,9 +27,9 @@
/*-------------------------------------------------------------------------
* Function: main
- * Generate an HDF5 file with groups, datasets and symbolic links.
*
- * After this file is generated, write bad offset values to
+ * Generate an HDF5 file with groups, datasets and symbolic links.
+ * After the file is generated, write bad offset values to
* the heap at 3 locations in the file:
* (A) Open the file:
* fd = HDopen(TESTFILE, O_RDWR, 0663);
@@ -40,7 +40,7 @@
* "/dsetA": replace name offset into private heap "72" by bad offset
* (3) HDlseek(fd, (HDoff_t)1616, SEEK_SET);
* /soft_one: replace link value offset in the scratch pad "32" by bad offset
- * (C) Write the bad offset value to the file:
+ * (C) Write the bad offset value to the file for (1), (2) and (3):
* write(fd, &val, sizeof(val));
*
* Note: if the groups/datasets/symbolic links are changed in the file,
@@ -55,6 +55,8 @@ main(void)
{
hid_t fid = -1, gid1 = -1, gid2 = -1; /* File and group IDs */
hid_t did = -1, sid = -1; /* Dataset and dataspace IDs */
+ int fd = -1; /* File descriptor */
+ int64_t val = 999; /* Bad offset value */
/* Create the test file */
if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -96,6 +98,39 @@ main(void)
if(H5Fclose(fid) < 0)
FAIL_STACK_ERROR
+ /*
+ * Write bad offset values at 3 locations in the file
+ */
+
+ /* Open the file */
+ if((fd = HDopen(TESTFILE, O_RDWR, 0663)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Position the file for /group1/group2: replace heap offset "8" by bad offset */
+ if(HDlseek(fd, (HDoff_t)880, SEEK_SET) < 0)
+ FAIL_STACK_ERROR
+ /* Write the bad offset value to the file */
+ if(HDwrite(fd, &val, sizeof(val)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Position the file for /dsetA: replace name offset into private heap "72" by bad offset */
+ if(HDlseek(fd, (HDoff_t)1512, SEEK_SET) < 0)
+ FAIL_STACK_ERROR
+ /* Write the bad offset value to the file */
+ if(HDwrite(fd, &val, sizeof(val)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Position the file for /soft_one: replace link value offset in the scratch pad "32" by bad offset */
+ if(HDlseek(fd, (HDoff_t)1616, SEEK_SET) < 0)
+ FAIL_STACK_ERROR
+ /* Write the bad offset value to the file */
+ if(HDwrite(fd, &val, sizeof(val)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(HDclose(fd) < 0)
+ FAIL_STACK_ERROR
+
return EXIT_SUCCESS;
error:
diff --git a/test/tmisc.c b/test/tmisc.c
index 242e55a..102325a 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -5574,7 +5574,7 @@ test_misc(void)
test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */
test_misc31(); /* Test Reentering library through deprecated routines after H5close() */
test_misc32(); /* Test filter memory allocation functions */
- test_misc33(); /* ??? */
+ test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */
} /* test_misc() */