diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2012-01-05 15:16:03 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2012-01-05 15:16:03 (GMT) |
commit | d174933e1953dc11a32a4715beec166a2490487f (patch) | |
tree | df4274a5f10fab9a8375edefae8367aa295ad987 /tools/h5ls | |
parent | 7d0c15b7944577e94d02f7b4fb6a63977901adf0 (diff) | |
download | hdf5-d174933e1953dc11a32a4715beec166a2490487f.zip hdf5-d174933e1953dc11a32a4715beec166a2490487f.tar.gz hdf5-d174933e1953dc11a32a4715beec166a2490487f.tar.bz2 |
[svn-r21865] Purpose:
Fix for HDFFV-7838 h5ls: segfault for handling region reference in attribute with -v option
Description:
Segfault occurred when h5ls access region reference data in an attribute.
This didn't occurred when -v option was used.
The cause was "h5tool_format_t info;" struct variable members were accessed
without proper values were assigned (was NULL), so printf failed later in the code.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake-Windows (32-LE)
Diffstat (limited to 'tools/h5ls')
-rw-r--r-- | tools/h5ls/CMakeLists.txt | 21 | ||||
-rw-r--r-- | tools/h5ls/h5ls.c | 8 | ||||
-rw-r--r-- | tools/h5ls/testh5ls.sh.in | 11 |
3 files changed, 36 insertions, 4 deletions
diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt index 2bbe088..ad37da0 100644 --- a/tools/h5ls/CMakeLists.txt +++ b/tools/h5ls/CMakeLists.txt @@ -38,6 +38,8 @@ IF (BUILD_TESTING) tall-2.ls tarray1.ls tattr2.ls + tattrreg_le.ls + tattrreg_be.ls tcomp-1.ls tdataregbe.ls tdataregle.ls @@ -88,6 +90,7 @@ IF (BUILD_TESTING) tall.h5 tarray1.h5 tattr2.h5 + tattrreg.h5 tcompound.h5 tdatareg.h5 tdset.h5 @@ -395,16 +398,28 @@ IF (BUILD_TESTING) # enable -S for avoiding printing NATIVE types ADD_H5_TEST (tattr2 0 -w80 -v -S tattr2.h5) + # test for attribute with region references wo verbose mode + # ( HDFFV-7838, ) + IF (H5_WORDS_BIGENDIAN) + ADD_H5_TEST (tattrreg_be 0 -w80 -v -d tattrreg.h5) + ELSE (H5_WORDS_BIGENDIAN) + ADD_H5_TEST (tattrreg_le 0 -w80 -v -d tattrreg.h5) + ENDIF (H5_WORDS_BIGENDIAN) + # test for non-existing file ADD_H5_TEST (nosuchfile 1 nosuchfile.h5) + # test for variable length data types in verbose mode IF (H5_WORDS_BIGENDIAN) - # test for variable length data types in verbose mode ADD_H5_TEST (tvldtypes2be 0 -v tvldtypes1.h5) - # test for dataset region references data types in verbose mode - ADD_H5_TEST (tdataregbe 0 -v tdatareg.h5) ELSE (H5_WORDS_BIGENDIAN) ADD_H5_TEST (tvldtypes2le 0 -v tvldtypes1.h5) + ENDIF (H5_WORDS_BIGENDIAN) + + # test for dataset region references data types in verbose mode + IF (H5_WORDS_BIGENDIAN) + ADD_H5_TEST (tdataregbe 0 -v tdatareg.h5) + ELSE (H5_WORDS_BIGENDIAN) ADD_H5_TEST (tdataregle 0 -v tdatareg.h5) ENDIF (H5_WORDS_BIGENDIAN) diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index a00a9e1..66e588f 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1447,9 +1447,15 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo, info.line_suf = "\""; } /* end if */ - /* values of type reference */ + /* values of reference type formats */ + info.dset_format = "DSET-%s "; + info.dset_hidefileno = 1; + info.dset_blockformat_pre = "%sBlk%lu: "; + info.dset_ptformat_pre = "%sPt%lu: "; + info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT; info.obj_hidefileno = 0; + if(hexdump_g) p_type = H5Tcopy(type); else diff --git a/tools/h5ls/testh5ls.sh.in b/tools/h5ls/testh5ls.sh.in index bdf0af7..e2c204b 100644 --- a/tools/h5ls/testh5ls.sh.in +++ b/tools/h5ls/testh5ls.sh.in @@ -65,6 +65,7 @@ LIST_HDF5_TEST_FILES=" $SRC_H5LS_TESTFILES/tall.h5 $SRC_H5LS_TESTFILES/tarray1.h5 $SRC_H5LS_TESTFILES/tattr2.h5 +$SRC_H5LS_TESTFILES/tattrreg.h5 $SRC_H5LS_TESTFILES/tcompound.h5 $SRC_H5LS_TESTFILES/tdatareg.h5 $SRC_H5LS_TESTFILES/tdset.h5 @@ -94,6 +95,8 @@ $SRC_H5LS_TESTFILES/tall-1.ls $SRC_H5LS_TESTFILES/tall-2.ls $SRC_H5LS_TESTFILES/tarray1.ls $SRC_H5LS_TESTFILES/tattr2.ls +$SRC_H5LS_TESTFILES/tattrreg_le.ls +$SRC_H5LS_TESTFILES/tattrreg_be.ls $SRC_H5LS_TESTFILES/tcomp-1.ls $SRC_H5LS_TESTFILES/tdataregbe.ls $SRC_H5LS_TESTFILES/tdataregle.ls @@ -357,6 +360,14 @@ TOOLTEST tempty.ls 0 -w80 -d tempty.h5 # enable -S for avoiding printing NATIVE types TOOLTEST tattr2.ls 0 -w80 -v -S tattr2.h5 +# test for attribute with region references without verbose mode +# ( HDFFV-7838, ) +if test $WORDS_BIGENDIAN != "yes"; then +TOOLTEST tattrreg_le.ls 0 -w80 -v -d tattrreg.h5 +else +TOOLTEST tattrreg_be.ls 0 -w80 -v -d tattrreg.h5 +fi + # tests for error handling. # test for non-existing file TOOLTEST nosuchfile.ls 1 nosuchfile.h5 |