summaryrefslogtreecommitdiff
path: root/usr/src/lib/libshare/common/libshare.c
diff options
context:
space:
mode:
authordougm <none@none>2007-05-29 15:54:57 -0700
committerdougm <none@none>2007-05-29 15:54:57 -0700
commita335142544257a204dde1839676940d0e0432d06 (patch)
treebec2835caba82a4afffa4cc66e4f4265691399eb /usr/src/lib/libshare/common/libshare.c
parent858a4b9997a29c40b725e606eb9bc3ac0a8c765b (diff)
downloadillumos-joyent-a335142544257a204dde1839676940d0e0432d06.tar.gz
6548000 sharemgr dumps core on allocation failure
6549790 NFS sharemgr dumps core on allocation failure 6559696 sharemgr: get_one_filesystem() leaks zfs handles 6559699 sharemgr: sa_scf_init() leaks scf instance and scope
Diffstat (limited to 'usr/src/lib/libshare/common/libshare.c')
-rw-r--r--usr/src/lib/libshare/common/libshare.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/usr/src/lib/libshare/common/libshare.c b/usr/src/lib/libshare/common/libshare.c
index 6d43efbcff..8e4e9b3c91 100644
--- a/usr/src/lib/libshare/common/libshare.c
+++ b/usr/src/lib/libshare/common/libshare.c
@@ -974,11 +974,23 @@ sa_get_group(sa_handle_t handle, char *groupname)
if (impl_handle != NULL && impl_handle->tree != NULL) {
if (groupname != NULL) {
group = strdup(groupname);
- subgroup = strchr(group, '/');
- if (subgroup != NULL)
- *subgroup++ = '\0';
+ if (group != NULL) {
+ subgroup = strchr(group, '/');
+ if (subgroup != NULL)
+ *subgroup++ = '\0';
+ }
}
- node = find_group_by_name(impl_handle->tree, (xmlChar *)group);
+ /*
+ * We want to find the, possibly, named group. If
+ * group is not NULL, then lookup the name. If it is
+ * NULL, we only do the find if groupname is also
+ * NULL. This allows lookup of the "first" group in
+ * the internal list.
+ */
+ if (group != NULL || groupname == NULL)
+ node = find_group_by_name(impl_handle->tree,
+ (xmlChar *)group);
+
/* if a subgroup, find it before returning */
if (subgroup != NULL && node != NULL)
node = find_group_by_name(node, (xmlChar *)subgroup);