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/modules/vfs_posixacl.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'source3/modules/vfs_posixacl.c') diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index d304f6fe8e..407a3a1724 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -214,28 +214,27 @@ static bool smb_ace_to_internal(acl_entry_t posix_ace, static struct smb_acl_t *smb_acl_to_internal(acl_t acl) { - struct smb_acl_t *result = SMB_MALLOC_P(struct smb_acl_t); + struct smb_acl_t *result = sys_acl_init(0); int entry_id = ACL_FIRST_ENTRY; acl_entry_t e; if (result == NULL) { return NULL; } - ZERO_STRUCTP(result); while (acl_get_entry(acl, entry_id, &e) == 1) { entry_id = ACL_NEXT_ENTRY; - result = (struct smb_acl_t *)SMB_REALLOC( - result, sizeof(struct smb_acl_t) + - (sizeof(struct smb_acl_entry) * (result->count+1))); - if (result == NULL) { - DEBUG(0, ("SMB_REALLOC failed\n")); + result->acl = talloc_realloc(result, result->acl, + struct smb_acl_entry, result->count+1); + if (result->acl == NULL) { + TALLOC_FREE(result); + DEBUG(0, ("talloc_realloc failed\n")); errno = ENOMEM; return NULL; } if (!smb_ace_to_internal(e, &result->acl[result->count])) { - SAFE_FREE(result); + TALLOC_FREE(result); return NULL; } -- cgit