summaryrefslogtreecommitdiffstats
path: root/src/H5Gcache.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2018-06-07 16:30:08 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2018-06-07 16:30:08 (GMT)
commit551f15f8ae02ca9c995619b216121081eb07633e (patch)
tree995de8be59b4d8524753eba6b542ce4039d54c79 /src/H5Gcache.c
parentb8c6b68c35fa2be23ef488a1d81097ff3ed55000 (diff)
parent664186b91d9198915baca4c6dca3f7b03695d316 (diff)
downloadhdf5-551f15f8ae02ca9c995619b216121081eb07633e.zip
hdf5-551f15f8ae02ca9c995619b216121081eb07633e.tar.gz
hdf5-551f15f8ae02ca9c995619b216121081eb07633e.tar.bz2
Merge pull request #1106 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:1.8/master to 1.8/masterhdf5-1_8_21
* commit '664186b91d9198915baca4c6dca3f7b03695d316': (124 commits) Commit HDF5 1.8.21 release version strings. Update INSTALL and INSTALL_parallel files to remove references to ancient systems and add generic steps for building HDF5 on HPC clusters. Update various INSTALL files for 1.8.21 release. Add missing space and correct typo. Modified a section for newly supported systems and compilers (vs. 1.8.20 release); Brought edits for tools bug fixes from 1.10.2 RELEASE.txt as we agreed with Allen. It is my test under Larry's guidance. Remove build directory which was unintentionally committed. Updated MANIFEST Switch default build mode to production. Update version to 1.8.21 in anticipation of release. Fixed EED-319 Description: Added an html version for the C++ function mapping table and removed the single web page version. Updated cpp_doc_config to use the html file. Fixed some typos. Running "doxygen cpp_doc_config" successfully. HDFFV-10473 fix HDFFV-10398 attribute location Add missing C++ entries to RELEASE.txt. pre1 release. Add missing RELEASE.txt entries for C++. Update Windows test machines Fix soversion naming and update cmake scripts Update version in RELEASE.txt. Correct merge errors from hdf5_1_8. Fixed typos Fixed typos Fixed typos ...
Diffstat (limited to 'src/H5Gcache.c')
-rw-r--r--src/H5Gcache.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/H5Gcache.c b/src/H5Gcache.c
index 1ca80df..994c5bf 100644
--- a/src/H5Gcache.c
+++ b/src/H5Gcache.c
@@ -103,49 +103,43 @@ H5FL_SEQ_EXTERN(H5G_entry_t);
/*-------------------------------------------------------------------------
- * Function: H5G_node_load
+ * Function: H5G_node_load
*
- * Purpose: Loads a symbol table node from the file.
+ * Purpose: Loads a symbol table node from the file.
*
- * Return: Success: Ptr to the new table.
+ * Return: Success: Ptr to the new table.
+ * Failure: NULL
*
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
*-------------------------------------------------------------------------
*/
static H5G_node_t *
H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
{
- H5G_node_t *sym = NULL;
- H5WB_t *wb = NULL; /* Wrapped buffer for node data */
- uint8_t node_buf[H5G_NODE_BUF_SIZE]; /* Buffer for node */
- uint8_t *node; /* Pointer to node buffer */
+ H5G_node_t *sym = NULL;
+ H5WB_t *wb = NULL; /* Wrapped buffer for node data */
+ uint8_t node_buf[H5G_NODE_BUF_SIZE]; /* Buffer for node */
+ uint8_t *node; /* Pointer to node buffer */
const uint8_t *p;
- H5G_node_t *ret_value; /*for error handling */
+ const uint8_t *p_end;
+ H5G_node_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /*
- * Check arguments.
- */
+ /* Sanity checks */
HDassert(f);
HDassert(H5F_addr_defined(addr));
HDassert(udata);
- /*
- * Initialize variables.
- */
-
/* Allocate symbol table data structures */
if(NULL == (sym = H5FL_CALLOC(H5G_node_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
sym->node_size = H5G_NODE_SIZE(f);
if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f)))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Wrap the local buffer for serialized node info */
if(NULL == (wb = H5WB_wrap(node_buf, sizeof(node_buf))))
@@ -157,19 +151,24 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
/* Read the serialized symbol table node. */
if(H5F_block_read(f, H5FD_MEM_BTREE, addr, sym->node_size, dxpl_id, node) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node")
+ HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node")
/* Get temporary pointer to serialized node */
p = node;
+ /* Get a pointer to the end of the node. This ensures we don't run off
+ * the end of the buffer if the file is corrupt.
+ */
+ p_end = p + sym->node_size - 1;
+
/* magic */
if(HDmemcmp(p, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC))
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node signature")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node signature")
p += 4;
/* version */
if(H5G_NODE_VERS != *p++)
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node version")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node version")
/* reserved */
p++;
@@ -178,8 +177,8 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
UINT16DECODE(p, sym->nsyms);
/* entries */
- if(H5G__ent_decode_vec(f, &p, sym->entry, sym->nsyms) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries")
+ if(H5G__ent_decode_vec(f, &p, p_end, sym->entry, sym->nsyms) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries")
/* Set return value */
ret_value = sym;