summaryrefslogtreecommitdiffstats
path: root/source3/modules/vfs_aixacl_util.c
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/modules/vfs_aixacl_util.c
parent47082ad3fae086c168bfedaa2fba692eccff3145 (diff)
downloadsamba-dcfb6aad16b4b7b70a63340a17771d3f40aed1ce.tar.gz
samba-dcfb6aad16b4b7b70a63340a17771d3f40aed1ce.tar.xz
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/modules/vfs_aixacl_util.c')
-rw-r--r--source3/modules/vfs_aixacl_util.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/source3/modules/vfs_aixacl_util.c b/source3/modules/vfs_aixacl_util.c
index b359c401efe..bd5ccbbdc23 100644
--- a/source3/modules/vfs_aixacl_util.c
+++ b/source3/modules/vfs_aixacl_util.c
@@ -27,14 +27,13 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl)
struct acl_entry *acl_entry;
struct ace_id *idp;
- struct smb_acl_t *result = SMB_MALLOC_P(struct smb_acl_t);
+ struct smb_acl_t *result = sys_acl_init(0);
struct smb_acl_entry *ace;
int i;
if (result == NULL) {
return NULL;
}
- ZERO_STRUCTP(result);
/* Point to the first acl entry in the acl */
acl_entry = file_acl->acl_ext;
@@ -64,11 +63,9 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl)
idp = acl_entry->ace_id;
DEBUG(10,("idp->id_data is %d\n",idp->id_data[0]));
- result = SMB_REALLOC(result, sizeof(struct smb_acl_t) +
- (sizeof(struct smb_acl_entry) *
- (result->count+1)));
+ result->acl = talloc_realloc(result, result->acl, result->count+1);
if (result == NULL) {
- DEBUG(0, ("SMB_REALLOC failed\n"));
+ DEBUG(0, ("talloc_realloc failed\n"));
errno = ENOMEM;
return NULL;
}
@@ -117,7 +114,7 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl)
break;
default:
DEBUG(0, ("unknown ace->type\n"));
- SAFE_FREE(result);
+ TALLOC_FREE(result);
return(0);
}
@@ -141,15 +138,14 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl)
for( i = 1; i < 4; i++) {
DEBUG(10,("i is %d\n",i));
- result = 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"));
- errno = ENOMEM;
- DEBUG(0,("Error in AIX sys_acl_get_file is %d\n",errno));
- return NULL;
- }
+ result->acl = talloc_realloc(result, result->acl, result->count+1);
+ if (result->acl == NULL) {
+ TALLOC_FREE(result);
+ DEBUG(0, ("talloc_realloc failed\n"));
+ errno = ENOMEM;
+ DEBUG(0,("Error in AIX sys_acl_get_file is %d\n",errno));
+ return NULL;
+ }
ace = &result->acl[result->count];