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-09-06 03:51:40 (GMT)
commit38194b496d9a868de21c6bcc8bda3bf30690712e (patch)
tree5e4891c5d5cdf46d7e6a55db847a633f2cd88134 /test
parentccb68f709181942106eef92e3f39575add1792e6 (diff)
downloadhdf5-38194b496d9a868de21c6bcc8bda3bf30690712e.zip
hdf5-38194b496d9a868de21c6bcc8bda3bf30690712e.tar.gz
hdf5-38194b496d9a868de21c6bcc8bda3bf30690712e.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 980c9ea..aae1a99 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -5525,7 +5525,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() */