summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Telka <marcel.telka@nexenta.com>2014-06-09 18:02:26 +0200
committerRobert Mustacchi <rm@joyent.com>2014-06-13 14:58:11 -0700
commit3253d86fb73285619825921040bf0262898cf3f8 (patch)
tree3a78b73f6ab6e5ecb8156c12100fb032e9f699ed
parent6020a1b764797bc75c5b6bb622762df54ebc0ff3 (diff)
downloadillumos-joyent-3253d86fb73285619825921040bf0262898cf3f8.tar.gz
4917 libshare_nfs: s_rootnames leaks
Reviewed by: Dan McDonald <danmcd@omniti.com> Reviewed by: Serghei Samsi <sscdvp@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/lib/libshare/nfs/libshare_nfs.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr/src/lib/libshare/nfs/libshare_nfs.c b/usr/src/lib/libshare/nfs/libshare_nfs.c
index 55a11fd072..a3b7305ac2 100644
--- a/usr/src/lib/libshare/nfs/libshare_nfs.c
+++ b/usr/src/lib/libshare/nfs/libshare_nfs.c
@@ -1041,14 +1041,17 @@ cleanup_export(struct exportdata *export)
{
int i;
- if (export->ex_index != NULL)
- free(export->ex_index);
- if (export->ex_secinfo != NULL) {
- for (i = 0; i < export->ex_seccnt; i++)
- if (export->ex_secinfo[i].s_rootnames != NULL)
- free(export->ex_secinfo[i].s_rootnames);
- free(export->ex_secinfo);
+ free(export->ex_index);
+
+ for (i = 0; i < export->ex_seccnt; i++) {
+ struct secinfo *s = &export->ex_secinfo[i];
+
+ while (s->s_rootcnt > 0)
+ free(s->s_rootnames[--s->s_rootcnt]);
+
+ free(s->s_rootnames);
}
+ free(export->ex_secinfo);
}
/*
@@ -1084,6 +1087,8 @@ get_rootnames(seconfig_t *sec, char *list, int *count)
for (i = 0; i < c; i++) {
host = strtok(list, ":");
if (!nfs_get_root_principal(sec, host, &a[i])) {
+ while (i > 0)
+ free(a[--i]);
free(a);
a = NULL;
break;