From 0662f060b2e5917b70360ed10aca3993b60f1434 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Thu, 5 Dec 2019 12:35:20 -0600 Subject: Fix the segmentation fault when h5dump "vds_virt_0.h5", which is a test file produced by test/vds.c in the develop branch. The fix: verify the decoded version for hyperslab selection is within the correct range. --- src/H5Shyper.c | 3 +++ src/H5Spkg.h | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 55913e0..4f96197 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -2481,6 +2481,9 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); + if(version < H5S_HYPER_VERSION_1 || version > H5S_HYPER_VERSION_LATEST) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for hyperslab selection") + if(version >= (uint32_t)H5S_HYPER_VERSION_2) { /* Decode flags */ flags = *(pp)++; diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 3edf4c3..518c495 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -37,8 +37,9 @@ #define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR) /* Versions for H5S_SEL_HYPER selection info */ -#define H5S_HYPER_VERSION_1 1 -#define H5S_HYPER_VERSION_2 2 +#define H5S_HYPER_VERSION_1 1 +#define H5S_HYPER_VERSION_2 2 +#define H5S_HYPER_VERSION_LATEST H5S_HYPER_VERSION_2 /* Versions for H5S_SEL_POINTS selection info */ #define H5S_POINT_VERSION_1 1 -- cgit v0.12