summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-01-24 18:09:57 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-01-24 18:09:57 (GMT)
commita6542d06b12340af99731eacb1d9687cdc8738ed (patch)
tree4852a2c3f1ac831c522a776bc3bfa95faa922a27
parente4dc71bbee2d38d01adb4a39bdf52a4c79e2d746 (diff)
downloadhdf5-a6542d06b12340af99731eacb1d9687cdc8738ed.zip
hdf5-a6542d06b12340af99731eacb1d9687cdc8738ed.tar.gz
hdf5-a6542d06b12340af99731eacb1d9687cdc8738ed.tar.bz2
[svn-r6330] Purpose:
Bug Fix Description: When calling H5Fopen with the core VFL driver, but without the H5F_ACC_CREAT flag goes ahead and creates a memory file. Solution: Check for the H5F_ACC_CREAT flag before allowing the memory file to be created. Platforms tested: FreeBSD 4.7 (sleipnir)
-rw-r--r--release_docs/RELEASE.txt2
-rw-r--r--src/H5FDcore.c2
-rw-r--r--test/Makefile.in4
-rw-r--r--test/tmisc.c33
4 files changed, 39 insertions, 2 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index ce903f9..62b8f86 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -35,6 +35,8 @@ Bug Fixes since HDF5-1.4.0
Library
-------
+ * H5Fopen without the H5F_ACC_CREAT flag should not succeed in creating
+ a new file with the 'core' VFL driver. QAK - 2003/01/24
* Allow opening objects with unknown object header messages.
QAK - 2003/01/21
* Improved error assertion for nil VL strings, making it fails with error
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 14ab106..fc56096 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -330,6 +330,8 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
FUNC_ENTER_NOAPI(H5FD_core_open, NULL);
/* Check arguments */
+ if (!(H5F_ACC_CREAT & flags))
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "must create core files, not open them");
if (0==maxaddr || HADDR_UNDEF==maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
diff --git a/test/Makefile.in b/test/Makefile.in
index 860c4cc..699a099 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -46,10 +46,10 @@ MOSTLYCLEAN=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \
gheap2.h5 gheap3.h5 gheap4.h5 links.h5 links[1-3].h5 big.data \
big[0-9][0-9][0-9][0-9][0-9].h5 dtypes[1-3].h5 tattr.h5 \
tselect.h5 mtime.h5 unlink.h5 fillval_[0-9].h5 fillval.raw \
- mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \
+ mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \
tvlstr.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 \
tgenprop.h5 tmisc.h5 tmisc2a.h5 tmisc2b.h5 tmisc3.h5 tmisc4a.h5 \
- tmisc4b.h5 tmisc5.h5 tmisc6.h5 tmisc7.h5 tmisc8.h5 \
+ tmisc4b.h5 tmisc5.h5 tmisc6.h5 tmisc7.h5 tmisc8.h5 tmisc9.h5 \
set_extent_read.h5 set_extent_create.h5 getname.h5 getname1.h5 \
getname2.h5 getname3.h5 sec2_file.h5 family_file000[0-3][0-9].h5 \
multi_file-[rs].h5 core_file new_move_[ab].h5
diff --git a/test/tmisc.c b/test/tmisc.c
index 6d86983..303aa17 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -137,6 +137,9 @@ typedef struct
#define MISC8_CHUNK_DIM0 10
#define MISC8_CHUNK_DIM1 10
+/* Definitions for misc. test #9 */
+#define MISC9_FILE "tmisc9.h5"
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -1538,6 +1541,34 @@ test_misc8(void)
/****************************************************************
**
+** test_misc9(): Test that H5Fopen() does not succeed for core
+** files, H5Fcreate() must be used to open them.
+**
+****************************************************************/
+static void
+test_misc9(void)
+{
+ hid_t fapl, fid;
+ herr_t ret;
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing core file opening\n"));
+
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ ret=H5Pset_fapl_core(fapl, 1024, 0);
+ CHECK(ret, FAIL, "H5Pset_fapl_core");
+
+ fid = H5Fopen(MISC9_FILE, H5F_ACC_RDWR, fapl);
+ VERIFY(fid,FAIL,"H5Fopen");
+
+ ret=H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pset_fapl_core");
+} /* end test_misc9() */
+
+/****************************************************************
+**
** test_misc(): Main misc. test routine.
**
****************************************************************/
@@ -1555,6 +1586,7 @@ test_misc(void)
test_misc6(); /* Test object header continuation code */
test_misc7(); /* Test for sensible datatypes stored on disk */
test_misc8(); /* Test storage sizes of various types of dataset storage */
+ test_misc9(); /* Test for opening (not creating) core files */
} /* test_misc() */
@@ -1586,4 +1618,5 @@ cleanup_misc(void)
remove(MISC6_FILE);
remove(MISC7_FILE);
remove(MISC8_FILE);
+ remove(MISC9_FILE);
}