This commit is contained in:
Binh-Minh Ribler 2018-03-15 09:09:49 -05:00
commit 9e6ee84e6b
9 changed files with 239 additions and 33 deletions

View File

@ -424,13 +424,19 @@ public class H5 implements java.io.Serializable {
private synchronized static native int H5dont_atexit() throws HDF5LibraryException;
/**
* Turn off error handling By default, the C library prints the error stack of the HDF-5 C library on stdout. This
* Turn off error handling. By default, the C library prints the error stack of the HDF-5 C library on stdout. This
* behavior may be disabled by calling H5error_off().
*
* @return a non-negative value if successful
*/
public synchronized static native int H5error_off();
/**
* Turn on error handling. By default, the C library prints the error stack of the HDF-5 C library on stdout. This
* behavior may be reenabled by calling H5error_on().
*/
public synchronized static native void H5error_on();
/**
* H5garbage_collect collects on all free-lists of all types.
*

View File

@ -33,6 +33,9 @@ extern "C" {
#include "h5jni.h"
#include "exceptionImp.h"
extern H5E_auto2_t efunc;
extern void *edata;
/*******************/
/* Local Variables */
@ -122,10 +125,24 @@ JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5error_1off
(JNIEnv *env, jclass clss)
{
H5Eget_auto2(H5E_DEFAULT, &efunc, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
return 0;
} /* end Java_hdf_hdf5lib_H5_H5error_1off() */
/*
* Class: hdf_hdf5lib_exceptions_HDF5Library
* Method: H5error_on
* Signature: ()V
*
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5error_1on
(JNIEnv *env, jclass clss)
{
H5Eset_auto2(H5E_DEFAULT, efunc, edata);
} /* end Java_hdf_hdf5lib_H5_H5error_1on() */
/*
* Class: hdf_hdf5lib_exceptions_HDFLibraryException

View File

@ -31,6 +31,16 @@ JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5error_1off
(JNIEnv *env, jclass clss );
/*
* Class: hdf_hdf5lib_exceptions_HDF5Library
* Method: H5error_on
* Signature: ()V
*
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5error_1on
(JNIEnv *env, jclass clss );
/*
* Class: hdf_hdf5lib_exceptions_HDFLibraryException

View File

@ -41,6 +41,9 @@ jobject get_callback;
jobject set_callback;
jobject delete_callback;
H5E_auto2_t efunc;
void *edata;
/********************/
/* Local Prototypes */
/********************/

View File

@ -86,6 +86,19 @@ New Features
Library:
--------
- Add an enumerated value to H5F_libver_t for H5Pset_libver_bounds().
Currently, the library defines two values for H5F_libver_t and supports
only two pairs of (low, high) combinations as derived from these values.
Thus the bounds setting via H5Pset_libver_bounds() is rather restricted.
Add an enumerated value (H5F_LIBVER_V18) to H5F_libver_t and
H5Pset_libver_bounds() now supports five pairs of (low, high) combinations
as derived from these values. This addition provides the user more
flexibility in setting bounds for object creation.
(VC - 2018/03/14)
- Add prefix option to VDS files.
Currently, VDS source files must be in the active directory to be
@ -271,6 +284,17 @@ Bug Fixes since HDF5-1.10.1 release
Library
-------
- Freeing of object header in H5Ocache.c
It was discovered that the object header was not released properly
when the checksum verification failed and a re-load of the object
header was needed.
Free the object header that failed the chksum verification only
after the new object header is reloaded, deserialized and set up.
(VC - 2018/03/14, HDFFV-10209)
- H5Pset_evict_on_close in H5Pfapl.c
Changed the minor error number from H5E_CANTSET to H5E_UNSUPPORTED for
@ -362,6 +386,26 @@ Bug Fixes since HDF5-1.10.1 release
(DER - 2018/02/26, HDFFV-10355)
- If an HDF5 file contains a malformed compound datatype with a
suitably large offset, the type conversion code can run off
the end of the type conversion buffer, causing a segmentation
fault.
This issue was reported to The HDF Group as issue #CVE-2017-17507.
NOTE: The HDF5 C library cannot produce such a file. This condition
should only occur in a corrupt (or deliberately altered) file
or a file created by third-party software.
THE HDF GROUP WILL NOT FIX THIS BUG AT THIS TIME
Fixing this problem would involve updating the publicly visible
H5T_conv_t function pointer typedef and versioning the API calls
which use it. We normally only modify the public API during
major releases, so this bug will not be fixed at this time.
(DER - 2018/02/26, HDFFV-10356)
- If an HDF5 file contains a malformed compound type which contains
a member of size zero, a division by zero error will occur while
processing the type.
@ -377,6 +421,23 @@ Bug Fixes since HDF5-1.10.1 release
(DER - 2018/02/26, HDFFV-10357)
- If an HDF5 file contains a malformed symbol table node that declares
it contains more symbols than it actually contains, the library
can run off the end of the metadata cache buffer while processing
the symbol table node.
This issue was reported to The HDF Group as issue #CVE-2017-17509.
NOTE: The HDF5 C library cannot produce such a file. This condition
should only occur in a corrupt (or deliberately altered) file
or a file created by third-party software.
Performing bounds checks on the buffer while processing fixes the
problem. Instead of the segmentation fault, the normal HDF5 error
handling is invoked.
(DER - 2018/03/12, HDFFV-10358)
Configuration
-------------
- CMake
@ -455,6 +516,20 @@ Bug Fixes since HDF5-1.10.1 release
Tools
-----
- h5clear
An enhancement to the tool in setting a file's stored EOA.
It was discovered that a crashed file's stored EOA in the superblock
was smaller than the actual file's EOF. When the file was reopened
and closed, the library truncated the file to the stored EOA.
Add an option to the tool in setting the file's stored EOA in the
superblock to the maximum of (EOA, EOF) + increment.
Another option is also added to print the file's EOA and EOF.
(VC - 2018/03/14, HDFFV-10360)
- h5repack
h5repack changes the chunk parameters when a change of layout is not
@ -647,7 +722,11 @@ Bug Fixes since HDF5-1.10.1 release
Testing
-------
-
- Memory for three variables in testphdf5's coll_write_test was malloced
but not freed, leaking memory when running the test. The variables'
memory is now freed.
(LRK - 2018/03/12, HDFFV-10397)
Supported Platforms
===================

View File

@ -170,6 +170,7 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata,
H5F_t *f = (H5F_t *)_udata; /* User data for callback */
H5G_node_t *sym = NULL; /* Symbol table node created */
const uint8_t *image = (const uint8_t *)_image; /* Pointer to image to deserialize */
const uint8_t *image_end = image + len - 1; /* Pointer to end of image buffer */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@ -203,7 +204,7 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata,
UINT16DECODE(image, sym->nsyms);
/* entries */
if(H5G__ent_decode_vec(f, &image, sym->entry, sym->nsyms) < 0)
if(H5G__ent_decode_vec(f, &image, image_end, sym->entry, sym->nsyms) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries")
/* Set return value */

View File

@ -91,7 +91,7 @@ H5FL_BLK_EXTERN(str_buf);
*-------------------------------------------------------------------------
*/
herr_t
H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n)
H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5G_entry_t *ent, unsigned n)
{
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@ -104,9 +104,12 @@ H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsign
HDassert(ent);
/* decode entries */
for(u = 0; u < n; u++)
for(u = 0; u < n; u++) {
if(*pp > p_end)
HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "ran off the end of the image buffer")
if(H5G_ent_decode(f, pp, ent + u) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode")
}
done:
FUNC_LEAVE_NOAPI(ret_value)

View File

@ -395,7 +395,7 @@ H5_DLL void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src,
H5_copy_depth_t depth);
H5_DLL void H5G__ent_reset(H5G_entry_t *ent);
H5_DLL herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp,
H5G_entry_t *ent, unsigned n);
const uint8_t *p_end, H5G_entry_t *ent, unsigned n);
H5_DLL herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp,
const H5G_entry_t *ent, unsigned n);
H5_DLL herr_t H5G__ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap,

View File

@ -108,6 +108,42 @@
endif ()
endmacro ()
macro (ADD_H5_CMP_WITH_COPY testname resultcode resultfile testfile)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
NAME H5CLEAR_CMP-${testname}-clear-objects
COMMAND ${CMAKE_COMMAND}
-E remove
testfiles/${testname}.out
testfiles/${testname}.out.err
testfiles/${testfile}
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test})
endif ()
add_test (
NAME H5CLEAR_CMP-copy_${testname}
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
"${PROJECT_SOURCE_DIR}/testfiles/${testfile}" "${PROJECT_BINARY_DIR}/testfiles/${testfile}"
)
set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects)
add_test (
NAME H5CLEAR_CMP-${testname}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5clear>"
-D "TEST_ARGS:STRING=${ARGN};${testfile}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${testname}.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}.ddl"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-copy_${testname})
set (last_test "H5CLEAR_CMP-${testname}")
endif ()
endmacro ()
macro (ADD_H5_RETTEST testname resultcode)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
@ -123,6 +159,70 @@
endif ()
endmacro ()
macro (ADD_H5_FILESIZE_TEST testname resultcode resultfile incr_size)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
NAME H5CLEAR_FILESIZE_TEST-${testname}-clear-objects
COMMAND ${CMAKE_COMMAND}
-E remove
testfiles/${testname}_before_size.out
testfiles/${testname}_before_size.out.err
testfiles/${testname}_after_size.out
testfiles/${testname}_after_size.out.err
testfiles/${testname}.h5
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (H5CLEAR_FILESIZE_TEST-${testname}-clear-objects PROPERTIES DEPENDS ${last_test})
endif ()
add_test (
NAME H5CLEAR_FILESIZE_TEST-copy_${testname}
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
"${PROJECT_SOURCE_DIR}/testfiles/${testname}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testname}.h5"
)
set_tests_properties (H5CLEAR_FILESIZE_TEST-copy_${testname} PROPERTIES DEPENDS H5CLEAR_FILESIZE_TEST-${testname}-clear-objects)
add_test (
NAME H5CLEAR_FILESIZE_CMP-${testname}_before_size
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5clear>"
-D "TEST_ARGS:STRING=--filesize;${testname}.h5"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${testname}_before_size.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}_before_size.ddl"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_before_size PROPERTIES DEPENDS H5CLEAR_FILESIZE_TEST-copy_${testname})
if (NOT ${incr_size} MATCHES "NONE")
add_test (
NAME H5CLEAR_FILESIZE_INCR-${testname}
COMMAND $<TARGET_FILE:h5clear> --increment=${incr_size} ${testname}.h5
)
else ()
add_test (
NAME H5CLEAR_FILESIZE_INCR-${testname}
COMMAND $<TARGET_FILE:h5clear> --increment ${testname}.h5
)
endif ()
set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WILL_FAIL "${resultcode}")
set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES DEPENDS H5CLEAR_FILESIZE_CMP-${testname}_before_size)
add_test (
NAME H5CLEAR_FILESIZE_CMP-${testname}_after_size
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5clear>"
-D "TEST_ARGS:STRING=--filesize;${testname}.h5"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${testname}_after_size.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}_after_size.ddl"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_after_size PROPERTIES DEPENDS H5CLEAR_FILESIZE_INCR-${testname})
set (last_test "H5CLEAR_FILESIZE_CMP-${testname}_after_size")
endif ()
endmacro ()
macro (ADD_H5_TEST testname testfile resultcode)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
@ -183,6 +283,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER)
latest_h5clear_sec2_v3.h5
mod_h5clear_mdc_image.h5
mod_h5clear_mdc_image2.h5
${HDF5_TEST_FILES}
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (H5CLEAR-clearall-objects PROPERTIES DEPENDS ${last_test})
@ -303,64 +404,50 @@ endif()
# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
# (no output, check exit code)
# "h5clear --filesize h5clear_status_noclose.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_open_fail_s h5clear_open_fail 1 "--filesize" h5clear_status_noclose.h5)
ADD_H5_RETTEST (h5clr_mdc_image "false" "-s" "--increment=0" h5clear_status_noclose.h5)
ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5)
ADD_H5_CMP_WITH_COPY (h5clr_open_fail_nc_s 1 h5clear_open_fail h5clear_status_noclose.h5 "--filesize")
ADD_H5_RETTEST (h5clr_mdc_image_nc "false" "-s" "--increment=0" h5clear_status_noclose.h5)
ADD_H5_CMP (h5clr_no_mdc_image_nc_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5)
#
# (2) h5clear_fsm_persist_noclose.h5
# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, just check exit code)
# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_open_fail_s h5clear_noclose_before_size 0 "--filesize" h5clear_fsm_persist_noclose.h5)
ADD_H5_RETTEST (h5clr_mdc_image "false" "--increment=0" h5clear_fsm_persist_noclose.h5)
ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_noclose_after_size 0 "--filesize" h5clear_fsm_persist_noclose.h5)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_noclose 0 h5clear_noclose 0)
#
# (3) h5clear_fsm_persist_equal.h5
# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_equal_before_size h5clear_equal_before_size 0 "--filesize" h5clear_fsm_persist_equal.h5)
ADD_H5_RETTEST (h5clr_equal_incr "false" "--increment" h5clear_fsm_persist_equal.h5)
ADD_H5_CMP (h5clr_equal_after_size h5clear_equal_after_size 0 "--filesize" h5clear_fsm_persist_equal.h5)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_equal 0 h5clear_equal NONE)
#
# (4) h5clear_fsm_persist_greater.h5
# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_greater_before_size h5clear_greater_before_size 0 "--filesize" h5clear_fsm_persist_greater.h5)
ADD_H5_RETTEST (h5clr_greater_incr "false" "--increment=0" h5clear_fsm_persist_greater.h5)
ADD_H5_CMP (h5clr_greater_after_size h5clear_greater_after_size 0 "--filesize" h5clear_fsm_persist_greater.h5)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_greater 0 h5clear_greater 0)
#
# (5) h5clear_fsm_persist_less.h5
# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_less_before_size h5clear_less_before_size 0 "--filesize" h5clear_fsm_persist_less.h5)
ADD_H5_RETTEST (h5clr_less_incr "false" "--increment=200" h5clear_fsm_persist_less.h5)
ADD_H5_CMP (h5clr_less_after_size h5clear_less_after_size 0 "--filesize" h5clear_fsm_persist_less.h5)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_less 0 h5clear_less 200)
#
# (6) h5clear_fsm_persist_user_equal.h5
# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_user_equal_before_size h5clear_user_equal_before_size 0 "--filesize" h5clear_fsm_persist_user_equal.h5)
ADD_H5_RETTEST (h5clr_user_equal_incr "false" "--increment" h5clear_fsm_persist_user_equal.h5)
ADD_H5_CMP (h5clr_user_equal_after_size h5clear_user_equal_after_size 0 "--filesize" h5clear_fsm_persist_user_equal.h5)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_user_equal 0 h5clear_user_equal NONE)
#
# (7) h5clear_fsm_persist_user_greater.h5
# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_user_greater_before_size h5clear_user_greater_before_size 0 "--filesize" h5clear_fsm_persist_user_greater.h5)
ADD_H5_RETTEST (h5clr_user_greater_incr "false" "--increment=0" h5clear_fsm_persist_user_greater.h5)
ADD_H5_CMP (h5clr_user_greater_after_size h5clear_user_greater_after_size 0 "--filesize" h5clear_fsm_persist_user_greater.h5)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_user_greater 0 h5clear_user_greater 0)
#
# (8) h5clear_fsm_persist_user_less.h5
# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
ADD_H5_CMP (h5clr_user_less_before_size h5clear_user_less_before_size 0 "--filesize" h5clear_fsm_persist_user_less.h5)
ADD_H5_RETTEST (h5clr_user_less_incr "false" "--increment=0" h5clear_fsm_persist_user_less.h5)
ADD_H5_CMP (h5clr_user_less_after_size h5clear_user_less_after_size 0 "--filesize" h5clear_fsm_persist_user_less.h5)
# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF before the next action)
# "h5clear --increment=200 h5clear_fsm_persist_user_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF after the last action)
ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_user_less 0 h5clear_user_less 200)
#
#