diff options
52 files changed, 382 insertions, 44 deletions
@@ -760,6 +760,7 @@ ./test/fillval.c ./test/flush1.c ./test/flush2.c +./test/gen_bad_ohdr.c _DO_NOT_DISTRIBUTE_ ./test/gen_bogus.c _DO_NOT_DISTRIBUTE_ ./test/gen_cross.c _DO_NOT_DISTRIBUTE_ ./test/gen_deflate.c _DO_NOT_DISTRIBUTE_ @@ -803,6 +804,7 @@ ./test/tarray.c ./test/tarrold.h5 ./test/tattr.c +./test/tbad_msg_count.h5 ./test/tbogus.h5 ./test/tchecksum.c ./test/tconfig.c diff --git a/Makefile.in b/Makefile.in index e8f00c0..ade6c24 100644 --- a/Makefile.in +++ b/Makefile.in @@ -221,6 +221,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/c++/Makefile.in b/c++/Makefile.in index be2bab8..b9662e7 100644 --- a/c++/Makefile.in +++ b/c++/Makefile.in @@ -192,6 +192,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in index e6b643a..992435f 100644 --- a/c++/examples/Makefile.in +++ b/c++/examples/Makefile.in @@ -186,6 +186,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index de7cc10..0ddfe15 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -222,6 +222,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 7cd387f..df28d21 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -208,6 +208,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ @@ -945,6 +945,7 @@ BUILD_ALL_CONDITIONAL_TRUE BUILD_ALL_CONDITIONAL_FALSE DEPRECATED_SYMBOLS DEFAULT_API_VERSION +STRICT_FORMAT_CHECKS BUILD_CXX_CONDITIONAL_TRUE BUILD_CXX_CONDITIONAL_FALSE BUILD_PARALLEL_CONDITIONAL_TRUE @@ -1616,6 +1617,9 @@ Optional Features: need [default=no] --enable-deprecated-symbols Enable deprecated public API symbols [default=yes] + --enable-strict-format-checks + Enable strict file format checks, default=yes if + debug flag is enabled, no otherwise Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -7923,7 +7927,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7926 "configure"' > conftest.$ac_ext + echo '#line 7930 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -10197,11 +10201,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:10200: $lt_compile\"" >&5) + (eval echo "\"\$as_me:10204: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:10204: \$? = $ac_status" >&5 + echo "$as_me:10208: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -10465,11 +10469,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:10468: $lt_compile\"" >&5) + (eval echo "\"\$as_me:10472: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:10472: \$? = $ac_status" >&5 + echo "$as_me:10476: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -10569,11 +10573,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:10572: $lt_compile\"" >&5) + (eval echo "\"\$as_me:10576: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:10576: \$? = $ac_status" >&5 + echo "$as_me:10580: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12949,7 +12953,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 12952 "configure" +#line 12956 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13049,7 +13053,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 13052 "configure" +#line 13056 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15401,11 +15405,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15404: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15408: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15408: \$? = $ac_status" >&5 + echo "$as_me:15412: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15505,11 +15509,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15508: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15512: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15512: \$? = $ac_status" >&5 + echo "$as_me:15516: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17075,11 +17079,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17078: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17082: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:17082: \$? = $ac_status" >&5 + echo "$as_me:17086: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -17179,11 +17183,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17182: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17186: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:17186: \$? = $ac_status" >&5 + echo "$as_me:17190: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19377,11 +19381,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19380: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19384: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19384: \$? = $ac_status" >&5 + echo "$as_me:19388: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19645,11 +19649,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19648: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19652: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19652: \$? = $ac_status" >&5 + echo "$as_me:19656: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19749,11 +19753,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19752: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19756: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19756: \$? = $ac_status" >&5 + echo "$as_me:19760: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -52088,6 +52092,43 @@ echo "$as_me: error: Removing old public API symbols not allowed when using them fi + +{ echo "$as_me:$LINENO: checking Whether to perform strict file format checks" >&5 +echo $ECHO_N "checking Whether to perform strict file format checks... $ECHO_C" >&6; }; +# Check whether --enable-strict-format-checks was given. +if test "${enable_strict_format_checks+set}" = set; then + enableval=$enable_strict_format_checks; STRICT_CHECKS=$enableval +fi + + +if test "X-$STRICT_CHECKS" = X- ; then + if test -z "$DEBUG_PKG" ; then + STRICT_CHECKS=no + else + STRICT_CHECKS=yes + fi +fi + +case "X-$STRICT_CHECKS" in + X-yes) + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + STRICT_FORMAT_CHECKS=yes + +cat >>confdefs.h <<\_ACEOF +#define STRICT_FORMAT_CHECKS 1 +_ACEOF + + ;; + X-no|*) + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + STRICT_FORMAT_CHECKS=no + ;; +esac + + + if test "X$HDF_CXX" = "Xyes"; then BUILD_CXX_CONDITIONAL_TRUE= BUILD_CXX_CONDITIONAL_FALSE='#' @@ -53143,6 +53184,7 @@ BUILD_ALL_CONDITIONAL_TRUE!$BUILD_ALL_CONDITIONAL_TRUE$ac_delim BUILD_ALL_CONDITIONAL_FALSE!$BUILD_ALL_CONDITIONAL_FALSE$ac_delim DEPRECATED_SYMBOLS!$DEPRECATED_SYMBOLS$ac_delim DEFAULT_API_VERSION!$DEFAULT_API_VERSION$ac_delim +STRICT_FORMAT_CHECKS!$STRICT_FORMAT_CHECKS$ac_delim BUILD_CXX_CONDITIONAL_TRUE!$BUILD_CXX_CONDITIONAL_TRUE$ac_delim BUILD_CXX_CONDITIONAL_FALSE!$BUILD_CXX_CONDITIONAL_FALSE$ac_delim BUILD_PARALLEL_CONDITIONAL_TRUE!$BUILD_PARALLEL_CONDITIONAL_TRUE$ac_delim @@ -53157,7 +53199,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 90; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -53953,6 +53995,9 @@ IF_ENABLED_DISABLED "$CODESTACK" PRINT_N " GPFS" IF_YES_NO "$GPFS" +PRINT_N " Strict File Format Checks" +IF_ENABLED_DISABLED "$STRICT_FORMAT_CHECKS" + PRINT_N " Default API Mapping" PRINT "$DEFAULT_API_VERSION" diff --git a/configure.in b/configure.in index 956ebe9..361322e 100644 --- a/configure.in +++ b/configure.in @@ -3645,6 +3645,41 @@ if test "X${DEFAULT_API_VERSION}" != "Xv18" -a "X${DEPRECATED_SYMBOLS}" = "Xno" AC_MSG_ERROR([Removing old public API symbols not allowed when using them as default public API symbols]) fi + +dnl ---------------------------------------------------------------------- +dnl Enable strict file format checks +dnl +AC_SUBST([STRICT_FORMAT_CHECKS]) +AC_MSG_CHECKING([Whether to perform strict file format checks]); +AC_ARG_ENABLE([strict-format-checks], + [AC_HELP_STRING([--enable-strict-format-checks], + [Enable strict file format checks, default=yes if + debug flag is enabled, no otherwise])], + [STRICT_CHECKS=$enableval]) + +dnl Default to yes if debug is enabled +if test "X-$STRICT_CHECKS" = X- ; then + if test -z "$DEBUG_PKG" ; then + STRICT_CHECKS=no + else + STRICT_CHECKS=yes + fi +fi + +case "X-$STRICT_CHECKS" in + X-yes) + AC_MSG_RESULT([yes]) + STRICT_FORMAT_CHECKS=yes + AC_DEFINE([STRICT_FORMAT_CHECKS], [1], + [Define if strict file format checks are enabled]) + ;; + X-no|*) + AC_MSG_RESULT([no]) + STRICT_FORMAT_CHECKS=no + ;; +esac + + dnl ---------------------------------------------------------------------- dnl Create automake conditionals to tell automake makefiles which directories dnl need to be compiled @@ -3952,6 +3987,9 @@ IF_ENABLED_DISABLED "$CODESTACK" PRINT_N " GPFS" IF_YES_NO "$GPFS" +PRINT_N " Strict File Format Checks" +IF_ENABLED_DISABLED "$STRICT_FORMAT_CHECKS" + PRINT_N " Default API Mapping" PRINT "$DEFAULT_API_VERSION" diff --git a/examples/Makefile.in b/examples/Makefile.in index f456fff..6dc5b22 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -186,6 +186,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/fortran/Makefile.in b/fortran/Makefile.in index 2d1edc6..215b5bf 100644 --- a/fortran/Makefile.in +++ b/fortran/Makefile.in @@ -196,6 +196,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in index 217ef52..e8fe92d 100644 --- a/fortran/examples/Makefile.in +++ b/fortran/examples/Makefile.in @@ -186,6 +186,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index 1862f18..31baee2 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -249,6 +249,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/fortran/test/Makefile.in b/fortran/test/Makefile.in index 30dd71c..5e0b92f 100644 --- a/fortran/test/Makefile.in +++ b/fortran/test/Makefile.in @@ -242,6 +242,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/fortran/testpar/Makefile.in b/fortran/testpar/Makefile.in index 53583e2..bc0df83 100644 --- a/fortran/testpar/Makefile.in +++ b/fortran/testpar/Makefile.in @@ -199,6 +199,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/Makefile.in b/hl/Makefile.in index ab0b512..9e248ae 100755 --- a/hl/Makefile.in +++ b/hl/Makefile.in @@ -196,6 +196,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/c++/Makefile.in b/hl/c++/Makefile.in index c9ae4f2..cfae251 100644 --- a/hl/c++/Makefile.in +++ b/hl/c++/Makefile.in @@ -192,6 +192,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/c++/examples/Makefile.in b/hl/c++/examples/Makefile.in index a540e06..04b7e60 100644 --- a/hl/c++/examples/Makefile.in +++ b/hl/c++/examples/Makefile.in @@ -186,6 +186,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index ef44a6c..d5f9755 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -211,6 +211,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/c++/test/Makefile.in b/hl/c++/test/Makefile.in index 8439ff5..a05ebae 100644 --- a/hl/c++/test/Makefile.in +++ b/hl/c++/test/Makefile.in @@ -202,6 +202,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/examples/Makefile.in b/hl/examples/Makefile.in index a5a4d4f..bbe994d 100644 --- a/hl/examples/Makefile.in +++ b/hl/examples/Makefile.in @@ -186,6 +186,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/fortran/Makefile.in b/hl/fortran/Makefile.in index 8125e3b..ae50941 100644 --- a/hl/fortran/Makefile.in +++ b/hl/fortran/Makefile.in @@ -196,6 +196,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/fortran/examples/Makefile.in b/hl/fortran/examples/Makefile.in index d4f12d0..062251b 100644 --- a/hl/fortran/examples/Makefile.in +++ b/hl/fortran/examples/Makefile.in @@ -186,6 +186,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index a126837..0e28d46 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -216,6 +216,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/fortran/test/Makefile.in b/hl/fortran/test/Makefile.in index 2322eea..21aa1ad 100644 --- a/hl/fortran/test/Makefile.in +++ b/hl/fortran/test/Makefile.in @@ -206,6 +206,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index 278d5bf..fe85eb8 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -212,6 +212,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in index 19c1de4..29d44d0 100644 --- a/hl/test/Makefile.in +++ b/hl/test/Makefile.in @@ -222,6 +222,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/tools/Makefile.in b/hl/tools/Makefile.in index dc1f4f6..069c85c 100644 --- a/hl/tools/Makefile.in +++ b/hl/tools/Makefile.in @@ -193,6 +193,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/hl/tools/gif2h5/Makefile.in b/hl/tools/gif2h5/Makefile.in index 84c03cd..ede1783 100644 --- a/hl/tools/gif2h5/Makefile.in +++ b/hl/tools/gif2h5/Makefile.in @@ -214,6 +214,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/perform/Makefile.in b/perform/Makefile.in index 33998c4..3ba09a9 100644 --- a/perform/Makefile.in +++ b/perform/Makefile.in @@ -237,6 +237,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ @@ -1077,6 +1077,14 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, oh->version = H5O_VERSION_1; oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); +#ifdef H5O_ENABLE_BAD_MESG_COUNT + /* Check whether the "bad message count" property is set */ + if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { + /* Retrieve bad message count flag */ + if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") + } /* end if */ +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Set initial status flags */ oh->flags = oh_flags; diff --git a/src/H5Ocache.c b/src/H5Ocache.c index b5c8c7d..0d5765e 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -580,10 +580,25 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, if(merged_null_msgs) oh->cache_info.is_dirty = TRUE; +/* Don't check for the incorrect # of object header messages bug unless we've + * enabled strict format checking. This allows for older files, created with + * a version of the library that had a bug in tracking the correct # of header + * messages to be read in without the library fussing about things. -QAK + */ +#ifdef H5_STRICT_FORMAT_CHECKS /* Sanity check for the correct # of messages in object header */ if(oh->version == H5O_VERSION_1) if((oh->nmesgs + merged_null_msgs) != nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too few messages") +#else /* H5_STRICT_FORMAT_CHECKS */ + /* Check for incorrect # of messages in object header and if we have write + * access on the file, flag the object header as dirty, so it gets fixed. + */ + if(oh->version == H5O_VERSION_1) + if((oh->nmesgs + merged_null_msgs) != nmesgs && + (H5F_get_intent(f) & H5F_ACC_RDWR)) + oh->cache_info.is_dirty = TRUE; +#endif /* H5_STRICT_FORMAT_CHECKS */ #ifdef H5O_DEBUG H5O_assert(oh); @@ -710,7 +725,12 @@ H5O_assert(oh); *p++ = 0; /* Number of messages */ - UINT16ENCODE(p, oh->nmesgs); +#ifdef H5O_ENABLE_BAD_MESG_COUNT + if(oh->store_bad_mesg_count) + UINT16ENCODE(p, (oh->nmesgs - 1)) + else +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ + UINT16ENCODE(p, oh->nmesgs); /* Link count */ UINT32ENCODE(p, oh->nlink); diff --git a/src/H5Opkg.h b/src/H5Opkg.h index c90ff0a..e2c5661 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -253,6 +253,12 @@ struct H5O_t { /* File-specific information (not stored) */ size_t sizeof_size; /* Size of file sizes */ size_t sizeof_addr; /* Size of file addresses */ +#ifdef H5O_ENABLE_BAD_MESG_COUNT + hbool_t store_bad_mesg_count; /* Flag to indicate that a bad message count should be stored */ + /* (This is to simulate a bug in earlier + * versions of the library) + */ +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Object information (stored) */ hbool_t has_refcount_msg; /* Whether the object has a ref. count message */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 72d9e2d..4a55ac2 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -91,6 +91,10 @@ typedef struct H5O_t H5O_t; #define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ #define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) #endif /* H5O_ENABLE_BOGUS */ +#ifdef H5O_ENABLE_BAD_MESG_COUNT +#define H5O_BAD_MESG_COUNT_NAME "bad message count" /* Flag setting bad message count */ +#define H5O_BAD_MESG_COUNT_SIZE sizeof(hbool_t) +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* ========= Object Copy properties ============ */ #define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 0c89e98..5c767ef 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -570,6 +570,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define if strict file format checks are enabled */ +#undef STRICT_FORMAT_CHECKS + /* Define if your system supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) call. */ #undef SYSTEM_SCOPE_THREADS diff --git a/src/Makefile.in b/src/Makefile.in index 44bc4e7..e733039 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -269,6 +269,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/test/Makefile.am b/test/Makefile.am index 4f4951c..53df8bb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -59,7 +59,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat testmeta # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS=gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ +BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ gen_nullspace gen_udlinks space_overflow diff --git a/test/Makefile.in b/test/Makefile.in index 84f0737..7e47249 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -81,8 +81,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \ btree2$(EXEEXT) fheap$(EXEEXT) -am__EXEEXT_2 = gen_bogus$(EXEEXT) gen_cross$(EXEEXT) \ - gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ +am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ + gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \ gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \ @@ -173,6 +173,10 @@ flush2_SOURCES = flush2.c flush2_OBJECTS = flush2.$(OBJEXT) flush2_LDADD = $(LDADD) flush2_DEPENDENCIES = libh5test.la $(LIBHDF5) +gen_bad_ohdr_SOURCES = gen_bad_ohdr.c +gen_bad_ohdr_OBJECTS = gen_bad_ohdr.$(OBJEXT) +gen_bad_ohdr_LDADD = $(LDADD) +gen_bad_ohdr_DEPENDENCIES = libh5test.la $(LIBHDF5) gen_bogus_SOURCES = gen_bogus.c gen_bogus_OBJECTS = gen_bogus.$(OBJEXT) gen_bogus_LDADD = $(LDADD) @@ -331,24 +335,26 @@ SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \ cache_api.c cmpd_dset.c cross_read.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ error_test.c extend.c external.c fheap.c fillval.c flush1.c \ - flush2.c gen_bogus.c gen_cross.c gen_deflate.c gen_filters.c \ - gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ - gen_new_super.c gen_noencoder.c gen_nullspace.c gen_udlinks.c \ - getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ - mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \ - set_extent.c space_overflow.c stab.c $(testhdf5_SOURCES) \ - testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c + flush2.c gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \ + gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \ + gen_new_mtime.c gen_new_super.c gen_noencoder.c \ + gen_nullspace.c gen_udlinks.c getname.c gheap.c hyperslab.c \ + istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \ + ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \ + $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ + vfd.c DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \ cache.c cache_api.c cmpd_dset.c cross_read.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ error_test.c extend.c external.c fheap.c fillval.c flush1.c \ - flush2.c gen_bogus.c gen_cross.c gen_deflate.c gen_filters.c \ - gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ - gen_new_super.c gen_noencoder.c gen_nullspace.c gen_udlinks.c \ - getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ - mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \ - set_extent.c space_overflow.c stab.c $(testhdf5_SOURCES) \ - testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c + flush2.c gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \ + gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \ + gen_new_mtime.c gen_new_super.c gen_noencoder.c \ + gen_nullspace.c gen_udlinks.c getname.c gheap.c hyperslab.c \ + istore.c lheap.c links.c mount.c mtime.c ntypes.c objcopy.c \ + ohdr.c pool.c reserved.c set_extent.c space_overflow.c stab.c \ + $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ + vfd.c ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -470,6 +476,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ @@ -631,7 +638,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \ # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS = gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ +BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ gen_nullspace gen_udlinks space_overflow @@ -798,6 +805,9 @@ flush1$(EXEEXT): $(flush1_OBJECTS) $(flush1_DEPENDENCIES) flush2$(EXEEXT): $(flush2_OBJECTS) $(flush2_DEPENDENCIES) @rm -f flush2$(EXEEXT) $(LINK) $(flush2_OBJECTS) $(flush2_LDADD) $(LIBS) +gen_bad_ohdr$(EXEEXT): $(gen_bad_ohdr_OBJECTS) $(gen_bad_ohdr_DEPENDENCIES) + @rm -f gen_bad_ohdr$(EXEEXT) + $(LINK) $(gen_bad_ohdr_OBJECTS) $(gen_bad_ohdr_LDADD) $(LIBS) gen_bogus$(EXEEXT): $(gen_bogus_OBJECTS) $(gen_bogus_DEPENDENCIES) @rm -f gen_bogus$(EXEEXT) $(LINK) $(gen_bogus_OBJECTS) $(gen_bogus_LDADD) $(LIBS) @@ -926,6 +936,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_bad_ohdr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_bogus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_cross.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_deflate.Po@am__quote@ diff --git a/test/gen_bad_ohdr.c b/test/gen_bad_ohdr.c new file mode 100644 index 0000000..d04996d --- /dev/null +++ b/test/gen_bad_ohdr.c @@ -0,0 +1,103 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Jan 5, 2008 + * + * Purpose: This program is run to generate an HDF5 data file with a + * root group that contains the incorrect # of object header + * messages. It must be built/run with a copy of the library + * that has been built with the "H5O_ENABLE_BAD_MESG_COUNT" macro + * defined. + */ + +#include "hdf5.h" +#include "H5private.h" +#include "H5Oprivate.h" + +#define FILENAME "tbad_msg_count.h5" +#define GROUPNAME "Group" +#define ATTRNAME1 "Attribute #1" +#define ATTRNAME2 "Attribute #2" + +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ + +int main(void) +{ +#ifdef H5O_ENABLE_BAD_MESG_COUNT + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t gcpl = -1; /* Group creation property list ID */ + hbool_t store_bad_mesg_count; /* Flag for storing a bad message count */ + + /* Create test file */ + if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + + /* Create group creation property list */ + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error; + + /* Add property for storing bad message count */ + store_bad_mesg_count = TRUE; + if(H5Pinsert2(gcpl, H5O_BAD_MESG_COUNT_NAME, H5O_BAD_MESG_COUNT_SIZE, &store_bad_mesg_count, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error; + + /* Create group with bad object header message count */ + if((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error; + + /* Close group creation property list */ + if(H5Pclose(gcpl) < 0) goto error; + + /* Create dataspace for attributes */ + if((sid = H5Screate(H5S_SCALAR)) < 0) goto error; + + /* Create attribute on root group */ + if((aid = H5Acreate2(gid, ATTRNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if(H5Aclose(aid) < 0) goto error; + + /* Create another attribute on root group */ + if((aid = H5Acreate2(gid, ATTRNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if(H5Aclose(aid) < 0) goto error; + + /* Close dataspace */ + if(H5Sclose(sid) < 0) goto error; + + /* Close group */ + if(H5Gclose(gid) < 0) goto error; + + /* Close file */ + if(H5Fclose(fid) < 0) goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(aid); + H5Sclose(sid); + H5Pclose(gcpl); + H5Fclose(fid); + } H5E_END_TRY; +#else /* H5O_ENABLE_BAD_MESG_COUNT */ + HDputs("H5O_BAD_MESG_COUNT compiler macro not defined!"); +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ + return 1; +} + diff --git a/test/tbad_msg_count.h5 b/test/tbad_msg_count.h5 Binary files differnew file mode 100644 index 0000000..ca5eb65 --- /dev/null +++ b/test/tbad_msg_count.h5 diff --git a/test/tmisc.c b/test/tmisc.c index cc4e5ec..915407c 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -295,6 +295,11 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset /* Definitions for misc. test #26 */ #define MISC26_FILE "dcpl_file" +/* Definitions for misc. test #27 */ +/* (Note that this test file is generated by the "gen_bad_ohdr.c" code) */ +#define MISC27_FILE "tbad_msg_count.h5" +#define MISC27_GROUP "Group" + /**************************************************************** ** ** test_misc1(): test unlinking a dataset from a group and immediately @@ -1709,7 +1714,7 @@ test_misc10(void) hid_t dcpl; /* Dataset creation property list */ hid_t space, type; /* Old dataset's dataspace & datatype */ char testfile[512]=""; /* Character buffer for corrected test file name */ - char *srcdir = getenv("srcdir"); /* Pointer to the directory the source code is located within */ + char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */ herr_t ret; /* Output message about test being performed */ @@ -4796,6 +4801,59 @@ test_misc26(void) CHECK_I(ret, "H5Pclose"); } + +/**************************************************************** +** +** test_misc27(): Ensure that objects with incorrect # of object +** header messages are handled appropriately. +** +** (Note that this test file is generated by the "gen_bad_ohdr.c" code) +** +****************************************************************/ +static void +test_misc27(void) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + char testfile[512]=""; /* Character buffer for corrected test file name */ + char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Corrupt object header handling\n")); + + /* Generate the correct name for the test file, by prepending the source path */ + if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC27_FILE) + 1) < sizeof(testfile))) { + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); + } + HDstrcat(testfile, MISC27_FILE); + + /* Open the file */ + fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + +#ifdef H5_STRICT_FORMAT_CHECKS + /* Open group with incorrect # of object header messages (should fail) */ + H5E_BEGIN_TRY { + gid = H5Gopen2(fid, MISC27_GROUP, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(gid, FAIL, "H5Gopen2"); +#else /* H5_STRICT_FORMAT_CHECKS */ + /* Open group with incorrect # of object header messages */ + gid = H5Gopen2(fid, MISC27_GROUP, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); + + /* Close group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); +#endif /* H5_STRICT_FORMAT_CHECKS */ + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_misc27() */ + /**************************************************************** ** ** test_misc(): Main misc. test routine. @@ -4837,6 +4895,7 @@ test_misc(void) test_misc25b(); /* Exercise null object header message merge bug on existing file */ test_misc25c(); /* Exercise another null object header message merge bug */ test_misc26(); /* Test closing property lists with long filter pipelines */ + test_misc27(); /* Test opening file with object that has bad # of object header messages */ } /* test_misc() */ diff --git a/testpar/Makefile.in b/testpar/Makefile.in index ba73cb2..0ef491a 100644 --- a/testpar/Makefile.in +++ b/testpar/Makefile.in @@ -229,6 +229,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/Makefile.in b/tools/Makefile.in index eabfca2..b61ce52 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -193,6 +193,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5copy/Makefile.in b/tools/h5copy/Makefile.in index 9eb5425..f21e156 100644 --- a/tools/h5copy/Makefile.in +++ b/tools/h5copy/Makefile.in @@ -210,6 +210,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in index 79c6ab6..92dbbe3 100644 --- a/tools/h5diff/Makefile.in +++ b/tools/h5diff/Makefile.in @@ -217,6 +217,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 4bb4ad9..03f729b 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -215,6 +215,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5import/Makefile.in b/tools/h5import/Makefile.in index 159e151..2d437f1 100755 --- a/tools/h5import/Makefile.in +++ b/tools/h5import/Makefile.in @@ -210,6 +210,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5jam/Makefile.in b/tools/h5jam/Makefile.in index 83555b1..500029b 100644 --- a/tools/h5jam/Makefile.in +++ b/tools/h5jam/Makefile.in @@ -221,6 +221,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5ls/Makefile.in b/tools/h5ls/Makefile.in index 605793a..ff0e8d5 100644 --- a/tools/h5ls/Makefile.in +++ b/tools/h5ls/Makefile.in @@ -204,6 +204,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 30f7b32..97d3620 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -224,6 +224,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/h5stat/Makefile.in b/tools/h5stat/Makefile.in index 33a3060..28106c4 100644 --- a/tools/h5stat/Makefile.in +++ b/tools/h5stat/Makefile.in @@ -213,6 +213,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in index 8de1275..ab8643d 100644 --- a/tools/lib/Makefile.in +++ b/tools/lib/Makefile.in @@ -209,6 +209,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in index 44d54c0..0644f5d 100644 --- a/tools/misc/Makefile.in +++ b/tools/misc/Makefile.in @@ -228,6 +228,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ |