diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-06-23 13:27:02 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-06-23 13:27:02 (GMT) |
commit | 88598fbeaad23233eae7ad7c9f0f5093fb2bdd2b (patch) | |
tree | 58c306f6f423fec036ef54976f669dfd16a29751 /src | |
parent | 8cb471ae995ce76e70fc5dcbde6c69a9c781600f (diff) | |
download | hdf5-88598fbeaad23233eae7ad7c9f0f5093fb2bdd2b.zip hdf5-88598fbeaad23233eae7ad7c9f0f5093fb2bdd2b.tar.gz hdf5-88598fbeaad23233eae7ad7c9f0f5093fb2bdd2b.tar.bz2 |
[svn-r7082] Purpose:
Bug fix (backward compatibility)
Description:
Track changes to allow H5Giterate to pass along iterator callback's return
value
Also, improve range checking on "index" parameter to disallow invalid
starting indices (<0 or > the number of objects in a group).
Platforms tested:
FreeBSD 4.8 (sleipnir)
h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5G.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -393,6 +393,8 @@ H5Giterate(hid_t loc_id, const char *name, int *idx, HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); if (!idx) idx = &_idx; + if (*idx<0) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); if (!op) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified"); @@ -401,10 +403,10 @@ H5Giterate(hid_t loc_id, const char *name, int *idx, * we can pass to the application-defined operator. */ if (NULL==(udata.group = H5G_open (loc, name, H5AC_dxpl_id))) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to open group"); + HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); if ((udata.group_id=H5I_register (H5I_GROUP, udata.group))<0) { H5G_close(udata.group); - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to register group"); + HGOTO_ERROR (H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group"); } /* Build udata to pass through H5B_iterate() to H5G_node_iterate() */ @@ -418,13 +420,18 @@ H5Giterate(hid_t loc_id, const char *name, int *idx, /* Iterate over the group members */ if ((ret_value = H5B_iterate (H5G_fileof(udata.group), H5AC_dxpl_id, H5B_SNODE, H5G_node_iterate, udata.group->ent.cache.stab.btree_addr, &udata))<0) - HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed"); + HERROR (H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); + + H5I_dec_ref (udata.group_id); /*also closes udata.group*/ + + /* Check for too high of a starting index (ex post facto :-) */ + /* (Skipping exactly as many entries as are in the group is currently an error) */ + if (*idx>0 && *idx>=udata.final_ent) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); /* Set the index we stopped at */ *idx=udata.final_ent; - H5I_dec_ref (udata.group_id); /*also closes udata.group*/ - done: FUNC_LEAVE_API(ret_value); } |