diff options
Diffstat (limited to 'usr/src/lib/libshare/common')
| -rw-r--r-- | usr/src/lib/libshare/common/libshare.c | 14 | ||||
| -rw-r--r-- | usr/src/lib/libshare/common/libshare_zfs.c | 1 | ||||
| -rw-r--r-- | usr/src/lib/libshare/common/libsharecore.c | 11 | ||||
| -rw-r--r-- | usr/src/lib/libshare/common/scfutil.c | 25 |
4 files changed, 37 insertions, 14 deletions
diff --git a/usr/src/lib/libshare/common/libshare.c b/usr/src/lib/libshare/common/libshare.c index 6af47e38c6..d8989a70ce 100644 --- a/usr/src/lib/libshare/common/libshare.c +++ b/usr/src/lib/libshare/common/libshare.c @@ -727,11 +727,13 @@ sa_optionset_name(sa_optionset_t optionset, char *oname, size_t len, char *id) } else { char *index; index = get_node_attr((void *)parent, "id"); - if (index != NULL) + if (index != NULL) { len = snprintf(oname, len, "%s_%s_%s", id, proto ? proto : "default", index); - else + sa_free_attr_string(index); + } else { len = 0; + } } if (proto != NULL) @@ -1387,7 +1389,6 @@ mark_excluded_protos(sa_group_t group, xmlNodePtr share, uint64_t flags) if (value == NULL) continue; features = sa_proto_get_featureset(value); - sa_free_attr_string(value); if (!(features & flags)) { (void) strlcat(exclude_list, sep, sizeof (exclude_list)); @@ -1395,6 +1396,7 @@ mark_excluded_protos(sa_group_t group, xmlNodePtr share, uint64_t flags) sizeof (exclude_list)); sep = ","; } + sa_free_attr_string(value); } if (exclude_list[0] != '\0') (void) xmlSetProp(share, (xmlChar *)"exclude", @@ -2043,7 +2045,7 @@ get_node_attr(void *nodehdl, char *tag) } /* - * get_node_attr(node, tag) + * set_node_attr(node, tag) * * Set the specified tag(attribute) to the specified value This is * used internally by a number of attribute oriented functions. It @@ -2897,6 +2899,8 @@ sa_create_security(sa_group_t group, char *sectype, char *proto) } } } + if (id != NULL) + sa_free_attr_string(id); if (groupname != NULL) sa_free_attr_string(groupname); return (security); @@ -3109,6 +3113,8 @@ sa_set_prop_by_prop(sa_optionset_t optionset, sa_group_t group, (void) sa_security_name(optionset, oname, sizeof (oname), id); ret = sa_start_transaction(scf_handle, oname); + if (id != NULL) + sa_free_attr_string(id); } if (ret == SA_OK) { switch (type) { diff --git a/usr/src/lib/libshare/common/libshare_zfs.c b/usr/src/lib/libshare/common/libshare_zfs.c index 7e461ba3b7..5adef70b4c 100644 --- a/usr/src/lib/libshare/common/libshare_zfs.c +++ b/usr/src/lib/libshare/common/libshare_zfs.c @@ -990,6 +990,7 @@ add_resources(sa_share_t share, char *opt) newopt = calloc(1, size); if (newopt != NULL) (void) snprintf(newopt, size, "%s,name=%s", opt, name); + sa_free_attr_string(name); free(opt); opt = newopt; propstr = sa_proto_legacy_format("smb", resource, 0); diff --git a/usr/src/lib/libshare/common/libsharecore.c b/usr/src/lib/libshare/common/libsharecore.c index 72d3420e1c..18e5f3c793 100644 --- a/usr/src/lib/libshare/common/libsharecore.c +++ b/usr/src/lib/libshare/common/libsharecore.c @@ -410,7 +410,7 @@ adddfsentry(xfs_sharelist_t *list, sa_share_t share, char *proto) if (item != NULL) { parent = sa_get_parent_group(share); groupname = sa_get_group_attr(parent, "name"); - if (strcmp(groupname, "default") == 0) { + if (groupname != NULL && strcmp(groupname, "default") == 0) { sa_free_attr_string(groupname); groupname = NULL; } @@ -691,11 +691,15 @@ sa_update_legacy(sa_share_t share, char *proto) * set or the type is not "transient". */ if (persist == NULL || strcmp(persist, "transient") != 0) { + path = sa_get_share_attr(share, "path"); + if (path == NULL) { + ret = SA_NO_MEMORY; + goto out; + } dfstab = open_dfstab(SA_LEGACY_DFSTAB); if (dfstab != NULL) { (void) setvbuf(dfstab, NULL, _IOLBF, BUFSIZ * 8); sablocksigs(&old); - path = sa_get_share_attr(share, "path"); (void) lockf(fileno(dfstab), F_LOCK, 0); list = getdfstab(dfstab); rewind(dfstab); @@ -708,7 +712,6 @@ sa_update_legacy(sa_share_t share, char *proto) (void) fsync(fileno(dfstab)); saunblocksigs(&old); (void) fclose(dfstab); - sa_free_attr_string(path); if (list != NULL) dfs_free_list(list); } else { @@ -717,7 +720,9 @@ sa_update_legacy(sa_share_t share, char *proto) else ret = SA_CONFIG_ERR; } + sa_free_attr_string(path); } +out: if (persist != NULL) sa_free_attr_string(persist); return (ret); diff --git a/usr/src/lib/libshare/common/scfutil.c b/usr/src/lib/libshare/common/scfutil.c index f5fabad540..21395d0731 100644 --- a/usr/src/lib/libshare/common/scfutil.c +++ b/usr/src/lib/libshare/common/scfutil.c @@ -20,12 +20,10 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* helper functions for using libscf with sharemgr */ #include <libscf.h> @@ -1585,7 +1583,7 @@ sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share) valstr ? valstr : ""); else (void) snprintf(propstr, strsize, "%s:%s:%s", - idstr ? idstr : "", valstr ? valstr : "", + idstr, valstr ? valstr : "", description ? description : ""); if (scf_value_set_astring(value, propstr) != 0) { ret = SA_SYSTEM_ERR; @@ -1604,16 +1602,29 @@ sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share) free(propstr); } err: - if (valstr != NULL) + if (valstr != NULL) { sa_free_attr_string(valstr); - if (idstr != NULL) + valstr = NULL; + } + if (idstr != NULL) { sa_free_attr_string(idstr); - if (description != NULL) + idstr = NULL; + } + if (description != NULL) { sa_free_share_description(description); + description = NULL; + } } /* the entry is in the transaction */ entry = NULL; + if (valstr != NULL) + sa_free_attr_string(valstr); + if (idstr != NULL) + sa_free_attr_string(idstr); + if (description != NULL) + sa_free_share_description(description); + if (ret == SA_SYSTEM_ERR) { switch (scf_error()) { case SCF_ERROR_PERMISSION_DENIED: |
