summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-18 23:36:49 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-18 23:36:49 (GMT)
commitf38864920d4e0bc8adaf9a23fd3f775ad90cb3f7 (patch)
treeb5f709e5415db2f1a9287b43565fea826b3018f5 /src/H5Oattr.c
parent4a17aff4085ad6ee265b95730aca3f493056dec8 (diff)
parent7aa4eb1b04014f1ad7e1c857ca6509aeeb6c0ae7 (diff)
downloadhdf5-f38864920d4e0bc8adaf9a23fd3f775ad90cb3f7.zip
hdf5-f38864920d4e0bc8adaf9a23fd3f775ad90cb3f7.tar.gz
hdf5-f38864920d4e0bc8adaf9a23fd3f775ad90cb3f7.tar.bz2
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into merge_func_enter_vol
Plus initial steps toward merging API context push into FUNC_ENTER_API* macros
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r--src/H5Oattr.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 441a938..f2c31d7 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -26,7 +26,7 @@
/* PRIVATE PROTOTYPES */
static herr_t H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg);
static void *H5O_attr_decode(H5F_t *f, H5O_t *open_oh,
- unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
+ unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p);
static void *H5O_attr_copy(const void *_mesg, void *_dest);
static size_t H5O_attr_size(const H5F_t *f, const void *_mesg);
static herr_t H5O__attr_free(void *mesg);
@@ -120,7 +120,7 @@ H5FL_EXTERN(H5S_extent_t);
--------------------------------------------------------------------------*/
static void *
H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
- unsigned *ioflags, const uint8_t *p)
+ unsigned *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p)
{
H5A_t *attr = NULL;
H5S_extent_t *extent; /*extent dimensionality information */
@@ -184,7 +184,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
/* Decode the attribute's datatype */
if(NULL == (attr->shared->dt = (H5T_t *)(H5O_MSG_DTYPE->decode)(f, open_oh,
- ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, p)))
+ ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->dt_size, p)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype")
if(attr->shared->version < H5O_ATTR_VERSION_2)
p += H5O_ALIGN_OLD(attr->shared->dt_size);
@@ -199,7 +199,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
/* Decode attribute's dataspace extent */
if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, open_oh,
- ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, p)) == NULL)
+ ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->ds_size, p)) == NULL)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace")
/* Copy the extent information to the dataspace */
@@ -614,14 +614,23 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src,
+H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src,
hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ const H5A_t *attr_src = (const H5A_t *)native_src; /* Source attribute */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
/* check args */
HDassert(deleted);
HDassert(cpy_info);
+ HDassert(cpy_info->file_dst);
+
+ /* Check to ensure that the version of the message to be copied does not exceed
+ the message version allowed by the destination file's high bound */
+ if(attr_src->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)])
+ HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "attribute message version out of bounds")
/* If we are not copying attributes into the destination file, indicate
* that this message should be deleted.
@@ -629,7 +638,8 @@ H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED
if(cpy_info->copy_without_attr)
*deleted = TRUE;
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_pre_copy_file() */