summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2004-07-20 00:47:37 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2004-07-20 00:47:37 (GMT)
commit24d36e1613a38a6d99e9c81ecd6d83063aec11b3 (patch)
tree34ea787b798eba19cbf488ba377ac624293606a4 /src/H5G.c
parent4e13d7afd521a9775f5888a960f273fbc695b4a1 (diff)
downloadhdf5-24d36e1613a38a6d99e9c81ecd6d83063aec11b3.zip
hdf5-24d36e1613a38a6d99e9c81ecd6d83063aec11b3.tar.gz
hdf5-24d36e1613a38a6d99e9c81ecd6d83063aec11b3.tar.bz2
[svn-r8897]
Purpose: Bug Fix Description: Trying to create the root group or the working group ("/" or ".") fakes out HDF5 so that it neither creates a group nor returns an error. Solution: H5G_namei now throws an error if it was supposed to insert but didn't. Platforms tested: sleipnir, Visual Studio 7 (very minor change) Misc. update:
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 27f43e8..310ee5f 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1359,6 +1359,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
unsigned null_grp; /* Flag to indicate this function was called with grp_ent set to NULL */
unsigned group_copy = 0; /* Flag to indicate that the group entry is copied */
unsigned last_comp = 0; /* Flag to indicate that a component is the last component in the name */
+ unsigned did_insert = 0; /* Flag to indicate that H5G_stab_insert was called */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_namei);
@@ -1481,6 +1482,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
}
} /* end if */
else {
+ did_insert = 1;
if (H5G_stab_insert(grp_ent, H5G_comp_g, ent, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert name");
HGOTO_DONE(SUCCEED);
@@ -1517,6 +1519,11 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
if (rest)
*rest = name; /*final null */
+ /* If this was an insert, make sure that the insert function was actually
+ * called (this catches no-op names like "." and "/") */
+ if( action== H5G_NAMEI_INSERT && !did_insert)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group already exists");
+
done:
/* If we started with a NULL obj_ent, free the entry information */
if(null_obj)