From d0a84b3ef337359d116b90278761c51c7a1826da Mon Sep 17 00:00:00 2001 From: jpandre Date: Wed, 24 Oct 2007 10:02:32 +0000 Subject: [PATCH] Fixed size returned in security API --- libntfs-3g/security.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index fc5a42f5..d2dffea0 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -4213,7 +4213,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection, avail = 0; phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr; - size = 0; + size = sizeof(SECURITY_DESCRIPTOR_RELATIVE); /* locate DACL if requested and available */ if (le16_to_cpu(phead->control) @@ -4221,7 +4221,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection, offdacl = le32_to_cpu(phead->dacl); pdacl = (const ACL*)&attr[offdacl]; daclsz = le16_to_cpu(pdacl->size); - size = offdacl + daclsz; + size += daclsz; avail |= DACL_SECURITY_INFORMATION; } else offdacl = daclsz = 0; @@ -4232,8 +4232,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection, /* find end of USID */ pusid = (const SID*)&attr[offowner]; usidsz = sid_size(pusid); - if ((offowner + usidsz) > size) - size = offowner + usidsz; + size += usidsz; avail |= OWNER_SECURITY_INFORMATION; } else offowner = usidsz = 0; @@ -4244,8 +4243,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection, /* find end of GSID */ pgsid = (const SID*)&attr[offgroup]; gsidsz = sid_size(pgsid); - if ((offgroup + gsidsz) > size) - size = offgroup + gsidsz; + size += gsidsz; avail |= GROUP_SECURITY_INFORMATION; } else offgroup = gsidsz = 0; @@ -4257,8 +4255,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection, offsacl = le32_to_cpu(phead->sacl); psacl = (const ACL*)&attr[offsacl]; saclsz = le16_to_cpu(psacl->size); - if ((offsacl + saclsz) > size) - size = offsacl + saclsz; + size += saclsz; avail |= SACL_SECURITY_INFORMATION; } else offsacl = saclsz = 0;