From e8170f588f25e96c08b5f319ab02079bddfb0926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Wed, 6 Apr 2016 10:02:23 +0200 Subject: [PATCH] Fixed the maximum size of an ACL Define the maximum size of an ACL as results from the maximum number of sub-authorities defined in layout.h --- include/ntfs-3g/acls.h | 5 +++-- libntfs-3g/acls.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/ntfs-3g/acls.h b/include/ntfs-3g/acls.h index a91eda7c..6506f78e 100644 --- a/include/ntfs-3g/acls.h +++ b/include/ntfs-3g/acls.h @@ -102,10 +102,11 @@ #define ROOT_GROUP_UNMARK FILE_READ_EA /* ACL granted to root as group */ /* - * A type large enough to hold any SID + * Maximum SID size and a type large enough to hold it */ -typedef char BIGSID[40]; +#define MAX_SID_SIZE (8 + SID_MAX_SUB_AUTHORITIES*4) +typedef char BIGSID[MAX_SID_SIZE]; /* * Struct to hold the input mapping file diff --git a/libntfs-3g/acls.c b/libntfs-3g/acls.c index 1df88aa6..524cc83c 100644 --- a/libntfs-3g/acls.c +++ b/libntfs-3g/acls.c @@ -2790,10 +2790,10 @@ char *ntfs_build_descr_posix(struct MAPPING* const mapping[], for (k=0; kacccnt; k++) { if ((pxdesc->acl.ace[k].tag == POSIX_ACL_USER) || (pxdesc->acl.ace[k].tag == POSIX_ACL_GROUP)) - newattrsz += 3*40; /* fixme : maximum size */ + newattrsz += 3*MAX_SID_SIZE; } /* account for default ACE's */ - newattrsz += 2*40*pxdesc->defcnt; /* fixme : maximum size */ + newattrsz += 2*MAX_SID_SIZE*pxdesc->defcnt; newattr = (char*)ntfs_malloc(newattrsz); if (newattr) { /* build the main header part */