summaryrefslogtreecommitdiffstats
path: root/src/H5Osdspace.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-10-26 19:55:54 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-10-26 19:55:54 (GMT)
commitf7545efc76fdb4e3fb7e93b93f0e404a3a651081 (patch)
tree29b59ab23912342bdaf6eaaf75fd2a0f8e1def46 /src/H5Osdspace.c
parentac90ad84f606a9482ee11caf417b017c6a28c1a9 (diff)
downloadhdf5-f7545efc76fdb4e3fb7e93b93f0e404a3a651081.zip
hdf5-f7545efc76fdb4e3fb7e93b93f0e404a3a651081.tar.gz
hdf5-f7545efc76fdb4e3fb7e93b93f0e404a3a651081.tar.bz2
[svn-r795] Changes since 19981026
---------------------- ./MANIFEST ./test/th5s.h5 [NEW] ./test/th5s.c Added a test to make sure that creating a data space with too large a rank fails. Added a test to make sure that reading a file that has a dataset with a space with too large a rank fails. Actually, this one is a little weird: the code that reads the data space message assumes the space is scalar if the message cannot be read. Fortunately the layout message fails also, preventing the dataset from being opened. However, since the data type message is still visible h5ls will report that the object is a named data type. ./test/space_overflow.c [NEW] This is the little program that makes the th5s.h5 file. ./src/H5A.c ./src/H5R.c ./src/H5Sselect.c Updated trace info. ./src/H5Olayout.c ./src/H5Osdspace.c Added code to fail if the dimensionality is too large when decoding a layout or simple data space message. ./src/H5Oprivate.h Redefined H5O_LAYOUT_NDIMS in terms of H5S_MAX_RANK. ./src/H5P.c ./src/H5S.c Check for ndims>H5S_MAX_RANK in API function calls, added assert to internal functions. ./src/H5V.c Changed a `<' to an `<=' in an assert. ./test/flush2.c Includes stdlib.h for getenv(). ./tools/h5tools.c Able to handle up to H5S_MAX_RANK dimensions during output.
Diffstat (limited to 'src/H5Osdspace.c')
-rw-r--r--src/H5Osdspace.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index d7727ef..adec06c 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -84,6 +84,7 @@ static void *
H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */
+ void *ret_value = NULL;
intn u; /* local counting variable */
uintn flags, version;
@@ -98,18 +99,22 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
if ((sdim = H5MM_calloc(sizeof(H5S_simple_t))) != NULL) {
version = *p++;
if (version!=H5O_SDSPACE_VERSION) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "wrong version number in data space message");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
+ "wrong version number in data space message");
}
sdim->rank = *p++;
+ if (sdim->rank>H5S_MAX_RANK) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
+ "simple data space dimensionality is too large");
+ }
flags = *p++;
p += 5; /*reserved*/
if (sdim->rank > 0) {
if (NULL==(sdim->size=H5MM_malloc(sizeof(sdim->size[0])*
sdim->rank))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
}
for (u = 0; u < sdim->rank; u++) {
H5F_decode_length (f, p, sdim->size[u]);
@@ -117,8 +122,8 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
if (flags & H5S_VALID_MAX) {
if (NULL==(sdim->max=H5MM_malloc(sizeof(sdim->max[0])*
sdim->rank))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
}
for (u = 0; u < sdim->rank; u++) {
H5F_decode_length (f, p, sdim->max[u]);
@@ -128,8 +133,8 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
if (flags & H5S_VALID_PERM) {
if (NULL==(sdim->perm=H5MM_malloc(sizeof(sdim->perm[0])*
sdim->rank))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
}
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->perm[u]);
@@ -137,15 +142,11 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
#endif
}
}
+ ret_value = (void*)sdim; /*success*/
-#ifdef LATER
done:
-#endif /* LATER */
- if (sdim == NULL) { /* Error condition cleanup */
-
- }
- /* Normal function cleanup */
- FUNC_LEAVE(sdim);
+ if (!ret_value) H5MM_xfree(sdim);
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------