diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index e864ed54bb9..55a32eac2a7 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -250,7 +250,7 @@ DataType::p_decode() const } // Call C function to decode the binary object description - hid_t encoded_dtype_id = H5Tdecode(encoded_buf); + hid_t encoded_dtype_id = H5Tdecode2(encoded_buf, buf_size); // If H5Tdecode fails, raise exception if (encoded_dtype_id < 0) { @@ -924,7 +924,8 @@ DataType::close() // Free and reset buffer of encoded object description if it's been used if (encoded_buf != NULL) { delete[] encoded_buf; - buf_size = 0; + encoded_buf = NULL; + buf_size = 0; } } } diff --git a/fortran/src/H5Tf.c b/fortran/src/H5Tf.c index f6992f91712..1c61cac273a 100644 --- a/fortran/src/H5Tf.c +++ b/fortran/src/H5Tf.c @@ -1890,47 +1890,6 @@ h5tcommitted_c(hid_t_f *dtype_id) return ret_value; } -/****if* H5Tf/h5tdecode_c - * NAME - * h5tdecode_c - * PURPOSE - * Call H5Tdecode - * INPUTS - * - * buf - Buffer for the data space object to be decoded. - * OUTPUTS - * - * obj_id - Object_id (non-negative) - * - * RETURNS - * 0 on success, -1 on failure - * SOURCE - */ - -int_f -h5tdecode_c(_fcd buf, hid_t_f *obj_id) -/******/ -{ - int ret_value = -1; - unsigned char *c_buf = NULL; /* Buffer to hold C string */ - hid_t c_obj_id; - - /* - * Call H5Tdecode function. - */ - - c_buf = (unsigned char *)buf; - - c_obj_id = H5Tdecode(c_buf); - if (c_obj_id < 0) - return ret_value; - - *obj_id = (hid_t_f)c_obj_id; - ret_value = 0; - - return ret_value; -} - /****if* H5Tf/h5tencode_c * NAME * h5tencode_c diff --git a/fortran/src/H5Tff.F90 b/fortran/src/H5Tff.F90 index 1416493e4d7..4e2c2d93c51 100644 --- a/fortran/src/H5Tff.F90 +++ b/fortran/src/H5Tff.F90 @@ -1855,32 +1855,47 @@ END SUBROUTINE h5tcommitted_f !> !! \ingroup FH5T !! -!! \brief Decode A binary object description of data type and return a new object handle. +!! \brief Decode a binary object description of data type and return a new object handle. !! -!! \param buf Buffer for the data space object to be decoded. -!! \param obj_id Object ID. -!! \param hdferr \fortran_error +!! \param buf Buffer for the data space object to be decoded. +!! \param obj_id Object ID. +!! \param hdferr \fortran_error +!! \param buf_size Size of the buffer. !! -!! See C API: @ref H5Tdecode() +!! See C API: @ref H5Tdecode2() !! - SUBROUTINE h5tdecode_f(buf, obj_id, hdferr) +SUBROUTINE h5tdecode_f(buf, obj_id, hdferr, buf_size) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: buf INTEGER(HID_T), INTENT(OUT) :: obj_id INTEGER, INTENT(OUT) :: hdferr + INTEGER(SIZE_T), OPTIONAL, INTENT(IN) :: buf_size + + INTEGER(SIZE_T) :: buf_size_default + INTERFACE - INTEGER FUNCTION h5tdecode_c(buf, obj_id) BIND(C,NAME='h5tdecode_c') + INTEGER(HID_T) FUNCTION H5Tdecode2(buf, buf_size) BIND(C,NAME='H5Tdecode2') IMPORT :: C_CHAR - IMPORT :: HID_T + IMPORT :: HID_T, SIZE_T IMPLICIT NONE - CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: buf - INTEGER(HID_T), INTENT(OUT) :: obj_id - END FUNCTION h5tdecode_c + CHARACTER(KIND=C_CHAR), DIMENSION(*) :: buf + INTEGER(SIZE_T), VALUE :: buf_size + END FUNCTION H5Tdecode2 END INTERFACE - hdferr = h5tdecode_c(buf, obj_id) + IF(PRESENT(buf_size))THEN + buf_size_default = buf_size + ELSE + buf_size_default = LEN(buf) + ENDIF + + obj_id = H5Tdecode2(buf, buf_size_default) + + IF(obj_id.LT.0)THEN + hdferr = -1 + ENDIF - END SUBROUTINE h5tdecode_f +END SUBROUTINE h5tdecode_f !> !! \ingroup FH5T diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index 55d36da33b3..5096cbcfbab 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -327,7 +327,6 @@ H5_FCDLL int_f h5tvlen_create_c(hid_t_f *type_id, hid_t_f *vltype_id); H5_FCDLL int_f h5tis_variable_str_c(hid_t_f *type_id, int_f *flag); H5_FCDLL int_f h5tget_member_class_c(hid_t_f *type_id, int_f *member_no, int_f *cls); H5_FCDLL int_f h5tcommit_anon_c(hid_t_f *loc_id, hid_t_f *dtype_id, hid_t_f *tcpl_id, hid_t_f *tapl_id); -H5_FCDLL int_f h5tdecode_c(_fcd buf, hid_t_f *obj_id); H5_FCDLL int_f h5tencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc); H5_FCDLL int_f h5tget_create_plist_c(hid_t_f *dtype_id, hid_t_f *dtpl_id); H5_FCDLL int_f h5tcompiler_conv_c(hid_t_f *src_id, hid_t_f *dst_id, int_f *c_flag); diff --git a/fortran/test/tH5T.F90 b/fortran/test/tH5T.F90 index 2e006bc3a4f..6424230cdd4 100644 --- a/fortran/test/tH5T.F90 +++ b/fortran/test/tH5T.F90 @@ -109,6 +109,7 @@ SUBROUTINE compoundtest(cleanup, total_error) CHARACTER(LEN=1024) :: cmpd_buf INTEGER(SIZE_T) :: cmpd_buf_size=0 INTEGER(HID_T) :: decoded_tid1 + INTEGER(HID_T) :: decoded_tid2 INTEGER(HID_T) :: fixed_str1, fixed_str2 LOGICAL :: are_equal @@ -553,7 +554,10 @@ SUBROUTINE compoundtest(cleanup, total_error) CALL H5Tencode_f(dtype_id, cmpd_buf, cmpd_buf_size, error) CALL check("H5Tencode_f", error, total_error) - ! Try decoding bogus buffer + ! Try decoding bogus buffer with and without optional buffer size + + CALL H5Tdecode_f(cmpd_buf, decoded_tid1, error, cmpd_buf_size) + CALL verify("H5Tdecode_f", error, -1, total_error) CALL H5Tdecode_f(cmpd_buf, decoded_tid1, error) CALL verify("H5Tdecode_f", error, -1, total_error) @@ -562,7 +566,7 @@ SUBROUTINE compoundtest(cleanup, total_error) CALL check("H5Tencode_f", error, total_error) ! Decode from the compound buffer and return an object handle - CALL H5Tdecode_f(cmpd_buf, decoded_tid1, error) + CALL H5Tdecode_f(cmpd_buf, decoded_tid1, error, cmpd_buf_size) CALL check("H5Tdecode_f", error, total_error) ! Verify that the datatype was copied exactly @@ -570,6 +574,15 @@ SUBROUTINE compoundtest(cleanup, total_error) CALL H5Tequal_f(decoded_tid1, dtype_id, flag, error) CALL check("H5Tequal_f", error, total_error) CALL verify("H5Tequal_f", flag, .TRUE., total_error) + + ! Decode from the compound buffer without the optional parameter + CALL H5Tdecode_f(cmpd_buf, decoded_tid2, error) + CALL check("H5Tdecode_f", error, total_error) + + ! Verify that the datatype was copied exactly + CALL H5Tequal_f(decoded_tid2, dtype_id, flag, error) + CALL check("H5Tequal_f", error, total_error) + ! ! Close all open objects. ! diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index f630faba8e5..d8b778e6ad2 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -13865,6 +13865,9 @@ public static long H5Tcreate(int tclass, long size) throws HDF5LibraryException * @param buf * IN: Buffer for the data type object to be decoded. * + * @param buf_size + * IN: Size of the buffer. + * * @return a new object handle * * @exception HDF5LibraryException @@ -13872,9 +13875,9 @@ public static long H5Tcreate(int tclass, long size) throws HDF5LibraryException * @exception NullPointerException * buf is null. **/ - public static long H5Tdecode(byte[] buf) throws HDF5LibraryException, NullPointerException + public static long H5Tdecode(byte[] buf, long buf_size) throws HDF5LibraryException, NullPointerException { - long id = _H5Tdecode(buf); + long id = _H5Tdecode(buf, buf_size); if (id > 0) { log.trace("OPEN_IDS: H5Tdecode add {}", id); OPEN_IDS.add(id); @@ -13883,7 +13886,7 @@ public static long H5Tdecode(byte[] buf) throws HDF5LibraryException, NullPointe return id; } - private synchronized static native long _H5Tdecode(byte[] buf) + private synchronized static native long _H5Tdecode(byte[] buf, long buf_size) throws HDF5LibraryException, NullPointerException; /** diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index e870c4321cf..a7d67f698c5 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -180,6 +180,23 @@ New Features H5Iregister_type() will map to the new signature unless the library is explicitly configured to use an older version of the API. + - The H5Tdecode() signature has changed + + When provided malformed or too-small buffers, H5Tdecode() would crash. + The new buffer size parameter allows this to be reliably avoided. + + The old signature has been renamed to H5Tdecode1() and is considered + deprecated: + + hid_t H5Tdecode1(const void *buf); + + The new signature is H5Tdecode2(). New code should use this version: + + hid_t H5Tdecode2(const void *buf, size_t buf_size); + + H5Tdecode() will map to the new signature unless the library is + explicitly configured to use an older version of the API. + - H5F_LIBVER_LATEST is now an enum value This was previously #defined to the latest H5F_libver_t API version, but diff --git a/src/H5T.c b/src/H5T.c index b795aa0be36..12fc4ae0be2 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -3691,7 +3691,7 @@ H5Tencode(hid_t obj_id, void *buf, size_t *nalloc) } /* end H5Tencode() */ /*------------------------------------------------------------------------- - * Function: H5Tdecode + * Function: H5Tdecode2 * * Purpose: Decode a binary object description and return a new object * handle. @@ -3703,7 +3703,7 @@ H5Tencode(hid_t obj_id, void *buf, size_t *nalloc) *------------------------------------------------------------------------- */ hid_t -H5Tdecode(const void *buf) +H5Tdecode2(const void *buf, size_t buf_size) { H5T_t *dt; hid_t ret_value; /* Return value */ @@ -3714,13 +3714,8 @@ H5Tdecode(const void *buf) if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "empty buffer"); - /* Create datatype by decoding buffer - * There is no way to get the size of the buffer, so we pass in - * SIZE_MAX and assume the caller knows what they are doing. - * Really fixing this will require an H5Tdecode2() call that - * takes a size parameter. - */ - if (NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) + /* Create datatype by decoding buffer */ + if (NULL == (dt = H5T_decode(buf_size, buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, H5I_INVALID_HID, "can't decode object"); /* Register the type and return the ID */ @@ -3729,7 +3724,7 @@ H5Tdecode(const void *buf) done: FUNC_LEAVE_API(ret_value) -} /* end H5Tdecode() */ +} /* end H5Tdecode2() */ /*------------------------------------------------------------------------- * API functions are above; library-private functions are below... @@ -3812,10 +3807,16 @@ H5T_decode(size_t buf_size, const unsigned char *buf) if (NULL == (f = H5F_fake_alloc((uint8_t)0))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "can't allocate fake file struct"); + if (buf_size != SIZE_MAX && H5_IS_BUFFER_OVERFLOW(buf, 1, buf + buf_size - 1)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "buffer too small to be datatype message"); + /* Decode the type of the information */ if (*buf++ != H5O_DTYPE_ID) HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "not an encoded datatype"); + if (buf_size != SIZE_MAX && H5_IS_BUFFER_OVERFLOW(buf, 1, buf + buf_size - 1)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "buffer too small to be datatype message"); + /* Decode the version of the datatype information */ if (*buf++ != H5T_ENCODE_VERSION) HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, NULL, "unknown version of encoded datatype"); diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 8350cbb8af8..3c9bdf97fcc 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -187,4 +187,48 @@ H5Topen1(hid_t loc_id, const char *name) FUNC_LEAVE_API(ret_value) } /* end H5Topen1() */ + +/*------------------------------------------------------------------------- + * Function: H5Tdecode1 + * + * Purpose: Decode a binary object description and return a new object + * handle. + * + * Note: Deprecated in favor of H5Tdecode2 + * + * Return: Success: datatype ID(non-negative) + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +hid_t +H5Tdecode1(const void *buf) +{ + H5T_t *dt; + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + + /* Check args */ + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "empty buffer"); + + /* Create datatype by decoding buffer + * There is no way to get the size of the buffer, so we pass in + * SIZE_MAX and assume the caller knows what they are doing. + * Really fixing this will require an H5Tdecode2() call that + * takes a size parameter. + */ + if (NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, H5I_INVALID_HID, "can't decode object"); + + /* Register the type and return the ID */ + if ((ret_value = H5I_register(H5I_DATATYPE, dt, true)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Tdecode1() */ + #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 83083a48434..28670b4dfb3 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -1452,11 +1452,12 @@ H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc); * object handle * * \param[in] buf Buffer for the datatype object to be decoded + * \param[in] buf_size Size of the buffer * * \return \hid_t{datatype} * - * \details H5Tdecode() Given an object description of datatype in binary in a - * buffer, H5Tdecode() reconstructs the HDF5 datatype object and + * \details H5Tdecode2() Given an object description of datatype in binary in a + * buffer, H5Tdecode2() reconstructs the HDF5 datatype object and * returns a new object handle for it. The binary description of * the object is encoded by H5Tencode(). User is responsible for * passing in the right buffer. @@ -1465,10 +1466,11 @@ H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc); * with H5Tclose() when the identifier is no longer needed so that * resource leaks will not develop. * - * \since 1.2.0 + * \since 2.0.0 * */ -H5_DLL hid_t H5Tdecode(const void *buf); +H5_DLL hid_t H5Tdecode2(const void *buf, size_t buf_size); + /** * \ingroup H5T * @@ -2910,6 +2912,35 @@ H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *bu /* Typedefs */ /* Function prototypes */ +/** + * \ingroup H5T + * + * \brief Decodes a binary object description of datatype and returns a new + * object handle + * + * \param[in] buf Buffer for the datatype object to be decoded + * + * \return \hid_t{datatype} + * + * \deprecated This function has been renamed from H5Tdecode() and is + * deprecated in favor of the macro #H5Tdecode or the function + * H5Tdecode2(). + * + * \details H5Tdecode1() Given an object description of datatype in binary in a + * buffer, H5Tdecode() reconstructs the HDF5 datatype object and + * returns a new object handle for it. The binary description of + * the object is encoded by H5Tencode(). User is responsible for + * passing in the right buffer. + * + * The datatype identifier returned by this function can be released + * with H5Tclose() when the identifier is no longer needed so that + * resource leaks will not develop. + * \version 2.0.0 C function H5Tdecode() renamed to H5Tdecode1() and deprecated + * in this release. + * \since 1.8.0 + * + */ +H5_DLL hid_t H5Tdecode1(const void *buf); /** * \ingroup H5T * diff --git a/src/H5vers.txt b/src/H5vers.txt index ce17f889c7b..de65f1298c1 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -86,6 +86,7 @@ FUNCTION: H5Tarray_create; ; v14, v18 FUNCTION: H5Tcommit; ; v10, v18 FUNCTION: H5Tget_array_dims; ; v14, v18 FUNCTION: H5Topen; ; v10, v18 +FUNCTION: H5Tdecode; ; v18, v200 # API typedefs # (although not required, it's easier to compare this file with the headers diff --git a/src/H5version.h b/src/H5version.h index 9fe80159695..55b2e22ff55 100644 --- a/src/H5version.h +++ b/src/H5version.h @@ -312,6 +312,10 @@ #define H5Tcommit_vers 2 #endif /* !defined(H5Tcommit_vers) */ +#if !defined(H5Tdecode_vers) + #define H5Tdecode_vers 1 +#endif /* !defined(H5Tdecode_vers) */ + #if !defined(H5Tget_array_dims_vers) #define H5Tget_array_dims_vers 2 #endif /* !defined(H5Tget_array_dims_vers) */ @@ -488,6 +492,10 @@ #define H5Tcommit_vers 2 #endif /* !defined(H5Tcommit_vers) */ +#if !defined(H5Tdecode_vers) + #define H5Tdecode_vers 1 +#endif /* !defined(H5Tdecode_vers) */ + #if !defined(H5Tget_array_dims_vers) #define H5Tget_array_dims_vers 2 #endif /* !defined(H5Tget_array_dims_vers) */ @@ -664,6 +672,10 @@ #define H5Tcommit_vers 2 #endif /* !defined(H5Tcommit_vers) */ +#if !defined(H5Tdecode_vers) + #define H5Tdecode_vers 1 +#endif /* !defined(H5Tdecode_vers) */ + #if !defined(H5Tget_array_dims_vers) #define H5Tget_array_dims_vers 2 #endif /* !defined(H5Tget_array_dims_vers) */ @@ -840,6 +852,10 @@ #define H5Tcommit_vers 2 #endif /* !defined(H5Tcommit_vers) */ +#if !defined(H5Tdecode_vers) + #define H5Tdecode_vers 1 +#endif /* !defined(H5Tdecode_vers) */ + #if !defined(H5Tget_array_dims_vers) #define H5Tget_array_dims_vers 2 #endif /* !defined(H5Tget_array_dims_vers) */ @@ -1016,6 +1032,10 @@ #define H5Tcommit_vers 2 #endif /* !defined(H5Tcommit_vers) */ +#if !defined(H5Tdecode_vers) + #define H5Tdecode_vers 2 +#endif /* !defined(H5Tdecode_vers) */ + #if !defined(H5Tget_array_dims_vers) #define H5Tget_array_dims_vers 2 #endif /* !defined(H5Tget_array_dims_vers) */ @@ -1472,6 +1492,17 @@ #error "H5Tcommit_vers set to invalid value" #endif /* H5Tcommit_vers */ +#if !defined(H5Tdecode_vers) || H5Tdecode_vers == 2 + #ifndef H5Tdecode_vers + #define H5Tdecode_vers 2 + #endif /* H5Tdecode_vers */ + #define H5Tdecode H5Tdecode2 +#elif H5Tdecode_vers == 1 + #define H5Tdecode H5Tdecode1 +#else /* H5Tdecode_vers */ + #error "H5Tdecode_vers set to invalid value" +#endif /* H5Tdecode_vers */ + #if !defined(H5Tget_array_dims_vers) || H5Tget_array_dims_vers == 2 #ifndef H5Tget_array_dims_vers #define H5Tget_array_dims_vers 2 diff --git a/test/dtypes.c b/test/dtypes.c index e0513e4b25f..3863f492523 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -8926,7 +8926,7 @@ test_set_size_invalid(void) *------------------------------------------------------------------------- */ static int -test_encode(void) +test_encode(bool H5_ATTR_DEPRECATED_USED use_old_decode_api) { struct cmpd { int a; @@ -8954,8 +8954,11 @@ test_encode(void) unsigned char *vlstr_buf = NULL; hid_t ret_id; herr_t ret; + char test_msg[128]; - TESTING("functions of encoding and decoding datatypes"); + snprintf(test_msg, sizeof(test_msg), "%s functions of encoding and decoding datatypes", + use_old_decode_api ? "old" : "new"); + TESTING(test_msg); /* Create File */ h5_fixname(FILENAME[5], H5P_DEFAULT, filename, sizeof filename); @@ -9059,7 +9062,14 @@ test_encode(void) /* Try decoding an incorrect (empty) buffer (should fail) */ H5E_BEGIN_TRY { - ret_id = H5Tdecode(cmpd_buf); +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + ret_id = H5Tdecode1(cmpd_buf); + else + ret_id = H5Tdecode2(cmpd_buf, cmpd_buf_size); +#else + ret_id = H5Tdecode2(cmpd_buf, cmpd_buf_size); +#endif } H5E_END_TRY if (ret_id != FAIL) { @@ -9075,7 +9085,16 @@ test_encode(void) } /* Decode from the compound buffer and return an object handle */ - if ((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0) +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + decoded_tid1 = H5Tdecode1(cmpd_buf); + else + decoded_tid1 = H5Tdecode2(cmpd_buf, cmpd_buf_size); +#else + decoded_tid1 = H5Tdecode2(cmpd_buf, cmpd_buf_size); +#endif + + if (decoded_tid1 < 0) FAIL_PUTS_ERROR("Can't decode compound type\n"); /* Verify that the datatype was copied exactly */ @@ -9114,7 +9133,16 @@ test_encode(void) } /* Decode from the enumerate buffer and return an object handle */ - if ((decoded_tid2 = H5Tdecode(enum_buf)) < 0) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + decoded_tid2 = H5Tdecode1(enum_buf); + else + decoded_tid2 = H5Tdecode2(enum_buf, enum_buf_size); +#else + decoded_tid2 = H5Tdecode2(enum_buf, enum_buf_size); +#endif + + if (decoded_tid2 < 0) { H5_FAILED(); printf("Can't decode enumerate type\n"); goto error; @@ -9156,7 +9184,16 @@ test_encode(void) } /* Decode from the VL string buffer and return an object handle */ - if ((decoded_tid3 = H5Tdecode(vlstr_buf)) < 0) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + decoded_tid3 = H5Tdecode1(vlstr_buf); + else + decoded_tid3 = H5Tdecode2(vlstr_buf, vlstr_buf_size); +#else + decoded_tid3 = H5Tdecode2(vlstr_buf, vlstr_buf_size); +#endif + + if (decoded_tid3 < 0) { H5_FAILED(); printf("Can't decode VL string type\n"); goto error; @@ -9264,7 +9301,16 @@ test_encode(void) } /* Decode from the compound buffer and return an object handle */ - if ((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0) +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + decoded_tid1 = H5Tdecode1(cmpd_buf); + else + decoded_tid1 = H5Tdecode2(cmpd_buf, cmpd_buf_size); +#else + decoded_tid1 = H5Tdecode2(cmpd_buf, cmpd_buf_size); +#endif + + if (decoded_tid1 < 0) FAIL_PUTS_ERROR("Can't decode compound type\n"); /* Verify that the datatype was copied exactly */ @@ -9303,7 +9349,16 @@ test_encode(void) } /* Decode from the enumerate buffer and return an object handle */ - if ((decoded_tid2 = H5Tdecode(enum_buf)) < 0) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + decoded_tid2 = H5Tdecode1(enum_buf); + else + decoded_tid2 = H5Tdecode2(enum_buf, enum_buf_size); +#else + decoded_tid2 = H5Tdecode2(enum_buf, enum_buf_size); +#endif + + if (decoded_tid2 < 0) { H5_FAILED(); printf("Can't decode enumerate type\n"); goto error; @@ -9345,11 +9400,21 @@ test_encode(void) } /* Decode from the VL string buffer and return an object handle */ - if ((decoded_tid3 = H5Tdecode(vlstr_buf)) < 0) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + if (use_old_decode_api) + decoded_tid3 = H5Tdecode1(vlstr_buf); + else + decoded_tid3 = H5Tdecode2(vlstr_buf, vlstr_buf_size); +#else + decoded_tid3 = H5Tdecode2(vlstr_buf, vlstr_buf_size); +#endif + + if (decoded_tid3 < 0) { H5_FAILED(); printf("Can't decode VL string type\n"); goto error; } + free(vlstr_buf); /* Verify that the datatype was copied exactly */ @@ -12825,7 +12890,10 @@ main(void) nerrors += test_set_fields_offset(); nerrors += test_transient(fapl); nerrors += test_named(fapl); - nerrors += test_encode(); +#ifndef H5_NO_DEPRECATED_SYMBOLS + nerrors += test_encode(true); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + nerrors += test_encode(false); nerrors += test_latest(); nerrors += test_int_float_except(); nerrors += test_named_indirect_reopen(fapl);