X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/87531e6302dd9352730f29b4bde36b2b21d4038b..79daa5961899c1110b862b0d3b85276122503c69:/lib/sysacls.c diff --git a/lib/sysacls.c b/lib/sysacls.c index 008e4c18..7334fd40 100644 --- a/lib/sysacls.c +++ b/lib/sysacls.c @@ -2,6 +2,7 @@ * Unix SMB/CIFS implementation. * Based on the Samba ACL support code. * Copyright (C) Jeremy Allison 2000. + * Copyright (C) 2007-2008 Wayne Davison * * The permission functions have been changed to get/set all bits via * one call. Some functions that rsync doesn't need were also removed. @@ -550,7 +551,7 @@ SMB_ACL_T sys_acl_init(int count) * acl[] array, this actually allocates an ACL with room * for (count+1) entries */ - if ((a = (SMB_ACL_T)SMB_MALLOC(sizeof(struct SMB_ACL_T) + count * sizeof(struct acl))) == NULL) { + if ((a = (SMB_ACL_T)SMB_MALLOC(sizeof a[0] + count * sizeof (struct acl))) == NULL) { errno = ENOMEM; return NULL; } @@ -1006,7 +1007,7 @@ SMB_ACL_T sys_acl_init(int count) * acl[] array, this actually allocates an ACL with room * for (count+1) entries */ - if ((a = SMB_MALLOC(sizeof(struct SMB_ACL_T) + count * sizeof(struct acl))) == NULL) { + if ((a = (SMB_ACL_T)SMB_MALLOC(sizeof a[0] + count * sizeof(struct acl))) == NULL) { errno = ENOMEM; return NULL; } @@ -1637,14 +1638,14 @@ SMB_ACL_T sys_acl_init(int count) return NULL; } - if ((a = SMB_MALLOC(sizeof(struct SMB_ACL_T) + sizeof(struct acl))) == NULL) { + if ((a = (SMB_ACL_T)SMB_MALLOC(sizeof a[0] + sizeof (struct acl))) == NULL) { errno = ENOMEM; return NULL; } a->next = -1; a->freeaclp = False; - a->aclp = (struct acl *)(&a->aclp + sizeof(struct acl *)); + a->aclp = (struct acl *)((char *)a + sizeof a[0]); a->aclp->acl_cnt = 0; return a; @@ -2703,6 +2704,8 @@ int sys_acl_set_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tag_type, uint32 bits, rc = mbr_uid_to_uuid(u_g_id, uu); else rc = mbr_gid_to_uuid(u_g_id, uu); + if (rc != 0) + return rc; if (acl_set_tag_type(entry, tag_type) != 0 || acl_set_qualifier(entry, &uu) != 0