diff options
-rw-r--r-- | librpc/idl/smb_acl.idl | 1 | ||||
-rw-r--r-- | source3/include/smb_acls.h | 2 | ||||
-rw-r--r-- | source3/lib/sysacls.c | 21 | ||||
-rw-r--r-- | source3/modules/vfs_posixacl.c | 2 | ||||
-rw-r--r-- | source3/smbd/posix_acls.c | 6 | ||||
-rw-r--r-- | source3/smbd/pysmbd.c | 2 |
6 files changed, 15 insertions, 19 deletions
diff --git a/librpc/idl/smb_acl.idl b/librpc/idl/smb_acl.idl index 2904c3afa4..f7332d9ac7 100644 --- a/librpc/idl/smb_acl.idl +++ b/librpc/idl/smb_acl.idl @@ -65,7 +65,6 @@ interface smb_acl } smb_acl_entry; [public] typedef struct { - [value(0)] int size; int count; [value(0)] int next; [size_is(count)] smb_acl_entry acl[*]; diff --git a/source3/include/smb_acls.h b/source3/include/smb_acls.h index 750bbc666a..dbcf3b7269 100644 --- a/source3/include/smb_acls.h +++ b/source3/include/smb_acls.h @@ -44,7 +44,7 @@ int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d); int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p); -SMB_ACL_T sys_acl_init(int count); +SMB_ACL_T sys_acl_init(void); int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p); int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type); int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p); diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c index 1b6eb9a35c..a5430d6a0d 100644 --- a/source3/lib/sysacls.c +++ b/source3/lib/sysacls.c @@ -249,25 +249,19 @@ char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p) return text; } -SMB_ACL_T sys_acl_init(int count) +SMB_ACL_T sys_acl_init(void) { SMB_ACL_T a; - if (count < 0) { - errno = EINVAL; - return NULL; - } - if ((a = talloc(NULL, struct smb_acl_t)) == NULL) { errno = ENOMEM; return NULL; } - a->size = count + 1; a->count = 0; a->next = -1; - a->acl = talloc_array(a, struct smb_acl_entry, count+1); + a->acl = talloc_array(a, struct smb_acl_entry, 0); if (!a->acl) { TALLOC_FREE(a); errno = ENOMEM; @@ -281,22 +275,25 @@ int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p) { SMB_ACL_T acl_d; SMB_ACL_ENTRY_T entry_d; + struct smb_acl_entry *acl; if (acl_p == NULL || entry_p == NULL || (acl_d = *acl_p) == NULL) { errno = EINVAL; return -1; } - if (acl_d->count >= acl_d->size) { - errno = ENOSPC; + acl = talloc_realloc(acl_d, acl_d->acl, struct smb_acl_entry, acl_d->count+1); + if (!acl) { + errno = ENOMEM; return -1; } - - entry_d = &acl_d->acl[acl_d->count++]; + acl_d->acl = acl; + entry_d = &acl_d->acl[acl_d->count]; entry_d->a_type = SMB_ACL_TAG_INVALID; entry_d->a_perm = 0; *entry_p = entry_d; + acl_d->count++; return 0; } diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index c9f8bd5f2d..50487ff4de 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -214,7 +214,7 @@ 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 = sys_acl_init(0); + struct smb_acl_t *result = sys_acl_init(); int entry_id = ACL_FIRST_ENTRY; acl_entry_t e; if (result == NULL) { diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index c5dea9c141..016acf4b31 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -2823,7 +2823,7 @@ static bool set_canon_ace_list(files_struct *fsp, { connection_struct *conn = fsp->conn; bool ret = False; - SMB_ACL_T the_acl = sys_acl_init(count_canon_ace_list(the_ace) + 1); + SMB_ACL_T the_acl = sys_acl_init(); canon_ace *p_ace; int i; SMB_ACL_ENTRY_T mask_entry; @@ -4524,7 +4524,7 @@ static bool unix_ex_wire_to_tagtype(unsigned char wire_tt, SMB_ACL_TAG_T *p_tt) static SMB_ACL_T create_posix_acl_from_wire(connection_struct *conn, uint16 num_acls, const char *pdata) { unsigned int i; - SMB_ACL_T the_acl = sys_acl_init(num_acls); + SMB_ACL_T the_acl = sys_acl_init(); if (the_acl == NULL) { return NULL; @@ -4668,7 +4668,7 @@ static bool remove_posix_acl(connection_struct *conn, files_struct *fsp, const c SMB_ACL_ENTRY_T entry; bool ret = False; /* Create a new ACL with only 3 entries, u/g/w. */ - SMB_ACL_T new_file_acl = sys_acl_init(3); + SMB_ACL_T new_file_acl = sys_acl_init(); SMB_ACL_ENTRY_T user_ent = NULL; SMB_ACL_ENTRY_T group_ent = NULL; SMB_ACL_ENTRY_T other_ent = NULL; diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 74acc01a3a..9b9b358cd2 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -160,7 +160,7 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode) mode_t mode_other = chmod_mode & 07; SMB_ACL_ENTRY_T entry; - SMB_ACL_T acl = sys_acl_init(4); + SMB_ACL_T acl = sys_acl_init(); if (!acl) { return NULL; |