diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2017-08-23 21:35:19 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2017-08-23 21:35:19 (GMT) |
commit | f3b72e1bde7368a98adb327189c4403bbba7ca77 (patch) | |
tree | e6bdf034efbcfc282aabcbb6f9eaec94c81a7084 /src/H5Glink.c | |
parent | 1b647b18fee735086616bf99e1879e47bab0c72e (diff) | |
parent | 1ef8577a4aaaa4120a819ff36747fdca99abdc26 (diff) | |
download | hdf5-f3b72e1bde7368a98adb327189c4403bbba7ca77.zip hdf5-f3b72e1bde7368a98adb327189c4403bbba7ca77.tar.gz hdf5-f3b72e1bde7368a98adb327189c4403bbba7ca77.tar.bz2 |
Merge pull request #637 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:develop to develop
* commit '1ef8577a4aaaa4120a819ff36747fdca99abdc26':
Modifications based on comments from pull request review (1) Remove unnecessary asserts (2) Add code to insert bad offset values to the test file in gen_bad_offset.c
Fix for HDFFV-10216 segfault in H5G_node_cmp3 with corrupt h5 file Fix H5HL_offset_into() to return error when offset exceeds heap data block size. Also fix other places that call this routine to detect error return.
Diffstat (limited to 'src/H5Glink.c')
-rw-r--r-- | src/H5Glink.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/H5Glink.c b/src/H5Glink.c index d246ee7..e199f89 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -224,7 +224,10 @@ herr_t H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name) { - FUNC_ENTER_PACKAGE_NOERR + hbool_t dup_soft = FALSE; /* xstrdup the symbolic link name or not */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(lnk); @@ -236,18 +239,21 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, lnk->cset = H5F_DEFAULT_CSET; lnk->corder = 0; lnk->corder_valid = FALSE; /* Creation order not valid for this link */ - lnk->name = H5MM_xstrdup(name); - HDassert(lnk->name); + if((lnk->name = H5MM_xstrdup(name)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to duplicate link name") /* Object is a symbolic or hard link */ if(ent->type == H5G_CACHED_SLINK) { const char *s; /* Pointer to link value */ - s = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset); - HDassert(s); + if((s = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get symbolic link name") /* Copy the link value */ - lnk->u.soft.name = H5MM_xstrdup(s); + if((lnk->u.soft.name = H5MM_xstrdup(s)) == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to duplicate symbolic link name") + + dup_soft = TRUE; /* Set link type */ lnk->type = H5L_TYPE_SOFT; @@ -260,7 +266,14 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, lnk->type = H5L_TYPE_HARD; } /* end else */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + if(ret_value < 0) { + if(lnk->name) + H5MM_xfree(lnk->name); + if(ent->type == H5G_CACHED_SLINK && dup_soft) + H5MM_xfree(lnk->u.soft.name); + } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_to_link() */ |