diff options
author | vchoi <vchoi@jelly.ad.hdfgroup.org> | 2020-03-12 20:44:43 (GMT) |
---|---|---|
committer | vchoi <vchoi@jelly.ad.hdfgroup.org> | 2020-03-12 20:44:43 (GMT) |
commit | 19464e2172e5b5d15d4a8ebaee57ef4bc671d897 (patch) | |
tree | 688e7d8063c6dd6f4594b1fe4784951e7aac95ce /src | |
parent | a64e09b1aec583e5dd4696e04e0320b786120d38 (diff) | |
download | hdf5-19464e2172e5b5d15d4a8ebaee57ef4bc671d897.zip hdf5-19464e2172e5b5d15d4a8ebaee57ef4bc671d897.tar.gz hdf5-19464e2172e5b5d15d4a8ebaee57ef4bc671d897.tar.bz2 |
Verify the decoded version for "all" and "none" selection.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Sall.c | 14 | ||||
-rw-r--r-- | src/H5Snone.c | 14 | ||||
-rw-r--r-- | src/H5Spkg.h | 6 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/H5Sall.c b/src/H5Sall.c index d57e6c1..86ab0d8 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -516,7 +516,7 @@ H5S_all_serialize (const H5S_t *space, uint8_t *buf) /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ + UINT32ENCODE(buf, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */ @@ -544,13 +544,23 @@ H5S_all_serialize (const H5S_t *space, uint8_t *buf) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_all_deserialize(H5S_t *space, const uint8_t H5_ATTR_UNUSED *buf) +H5S_all_deserialize(H5S_t *space, const uint8_t *buf) { + uint32_t version; /* Decoded version */ + uint8_t *p; /* Temporary pointer to buf */ herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(space); + HDassert(buf); + + p = buf + 4; + /* Decode version */ + UINT32DECODE(p, version); + + if(version < H5S_ALL_VERSION_1 || version > H5S_ALL_VERSION_LATEST) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for all selection") /* Change to "all" selection */ if((ret_value = H5S_select_all(space, TRUE)) < 0) diff --git a/src/H5Snone.c b/src/H5Snone.c index 1c2af0b..ed20467 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -484,7 +484,7 @@ H5S_none_serialize(const H5S_t *space, uint8_t *buf) /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ + UINT32ENCODE(buf, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */ @@ -512,13 +512,23 @@ H5S_none_serialize(const H5S_t *space, uint8_t *buf) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_deserialize(H5S_t *space, const uint8_t H5_ATTR_UNUSED *buf) +H5S_none_deserialize(H5S_t *space, const uint8_t *buf) { + uint8_t *p; /* Temporary pointer to buf */ + uint32_t version; /* Version number */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(space); + HDassert(buf); + + p = buf + 4; + /* Decode version */ + UINT32DECODE(p, version); + + if(version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for none selection") /* Change to "none" selection */ if(H5S_select_none(space) < 0) diff --git a/src/H5Spkg.h b/src/H5Spkg.h index db633b3..3dc7780 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -40,7 +40,13 @@ #define H5S_POINT_VERSION_1 1 #define H5S_POINT_VERSION_LATEST H5S_HYPER_VERSION_1 +/* Versions for H5S_SEL_NONE selection info */ +#define H5S_NONE_VERSION_1 1 +#define H5S_NONE_VERSION_LATEST H5S_NONE_VERSION_1 +/* Versions for H5S_SEL_ALL selection info */ +#define H5S_ALL_VERSION_1 1 +#define H5S_ALL_VERSION_LATEST H5S_ALL_VERSION_1 /* Initial version of the dataspace information */ #define H5O_SDSPACE_VERSION_1 1 |