From dcfb6aad16b4b7b70a63340a17771d3f40aed1ce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 12 Aug 2012 20:41:35 +1000 Subject: 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 --- source3/lib/sysacls.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source3/lib') 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; } -- cgit