diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-08-12 20:41:35 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-08-15 11:44:43 +1000 |
commit | dcfb6aad16b4b7b70a63340a17771d3f40aed1ce (patch) | |
tree | 642350bd8b0e54bdbb24bcd7b712c411eedd3441 /source3/modules/vfs_tru64acl.c | |
parent | 47082ad3fae086c168bfedaa2fba692eccff3145 (diff) | |
download | samba-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/modules/vfs_tru64acl.c')
-rw-r--r-- | source3/modules/vfs_tru64acl.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/source3/modules/vfs_tru64acl.c b/source3/modules/vfs_tru64acl.c index 3f91a4753a..09f8c3933f 100644 --- a/source3/modules/vfs_tru64acl.c +++ b/source3/modules/vfs_tru64acl.c @@ -160,28 +160,27 @@ static struct smb_acl_t *tru64_acl_to_smb_acl(const struct acl *tru64_acl) DEBUG(10, ("Hi! This is tru64_acl_to_smb_acl.\n")); - if ((result = SMB_MALLOC_P(struct smb_acl_t)) == NULL) { - DEBUG(0, ("SMB_MALLOC_P failed in tru64_acl_to_smb_acl\n")); + if ((result = sys_acl_init(0)) == NULL) { + DEBUG(0, ("sys_acl_init() failed in tru64_acl_to_smb_acl\n")); errno = ENOMEM; goto fail; } - ZERO_STRUCTP(result); if (acl_first_entry((struct acl *)tru64_acl) != 0) { DEBUG(10, ("acl_first_entry failed: %s\n", strerror(errno))); goto fail; } while ((entry = acl_get_entry((struct acl *)tru64_acl)) != NULL) { - 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 in tru64_acl_to_smb_acl\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 in tru64_acl_to_smb_acl\n")); errno = ENOMEM; goto fail; } /* XYZ */ if (!tru64_ace_to_smb_ace(entry, &result->acl[result->count])) { - SAFE_FREE(result); + TALLOC_FREE(result); goto fail; } result->count += 1; @@ -189,9 +188,7 @@ static struct smb_acl_t *tru64_acl_to_smb_acl(const struct acl *tru64_acl) return result; fail: - if (result != NULL) { - SAFE_FREE(result); - } + TALLOC_FREE(result); DEBUG(1, ("tru64_acl_to_smb_acl failed!\n")); return NULL; } |