summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-12 20:41:35 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-15 11:44:43 +1000
commitdcfb6aad16b4b7b70a63340a17771d3f40aed1ce (patch)
tree642350bd8b0e54bdbb24bcd7b712c411eedd3441 /source3/lib
parent47082ad3fae086c168bfedaa2fba692eccff3145 (diff)
downloadsamba-dcfb6aad16b4b7b70a63340a17771d3f40aed1ce.tar.gz
samba-dcfb6aad16b4b7b70a63340a17771d3f40aed1ce.tar.bz2
samba-dcfb6aad16b4b7b70a63340a17771d3f40aed1ce.zip
s3-smbd: Change allocation of smb_acl_t to talloc()
The acl element is changed to be a talloc child, and is no longer one element longer than requested by virtue of the acl[1] base pointer. This also avoids one of the few remaining cases of over-allocation of a structure. Andrew Bartlett
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/sysacls.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c
index 592aef6d43..7e387e444b 100644
--- a/source3/lib/sysacls.c
+++ b/source3/lib/sysacls.c
@@ -258,15 +258,7 @@ SMB_ACL_T sys_acl_init(int count)
return NULL;
}
- /*
- * note that since the definition of the structure pointed
- * to by the SMB_ACL_T includes the first element of the
- * acl[] array, this actually allocates an ACL with room
- * for (count+1) entries
- */
- if ((a = (struct smb_acl_t *)SMB_MALLOC(
- sizeof(struct smb_acl_t) +
- count * sizeof(struct smb_acl_entry))) == NULL) {
+ if ((a = talloc(NULL, struct smb_acl_t)) == NULL) {
errno = ENOMEM;
return NULL;
}
@@ -275,6 +267,13 @@ SMB_ACL_T sys_acl_init(int count)
a->count = 0;
a->next = -1;
+ a->acl = talloc_array(a, struct smb_acl_entry, count+1);
+ if (!a->acl) {
+ TALLOC_FREE(a);
+ errno = ENOMEM;
+ return NULL;
+ }
+
return a;
}
@@ -357,7 +356,7 @@ int sys_acl_free_text(char *text)
int sys_acl_free_acl(SMB_ACL_T acl_d)
{
- SAFE_FREE(acl_d);
+ TALLOC_FREE(acl_d);
return 0;
}