Fix bug in RtlpAddKnownAce() that caused it to place the SID in the wrong location.

Teach RtlpAddKnownAce() some status values other than STATUS_UNSUCCESSFUL.
(Patch by Joseph Galbraith)

svn path=/trunk/; revision=3089
This commit is contained in:
Eric Kohl 2002-06-15 10:09:17 +00:00
parent b6b3e3f14e
commit fd874ecc14
2 changed files with 64 additions and 64 deletions

View file

@ -1,4 +1,4 @@
/* $Id: acl.c,v 1.4 2002/06/07 22:59:19 ekohl Exp $ /* $Id: acl.c,v 1.5 2002/06/15 10:08:46 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -105,12 +105,12 @@ RtlpAddKnownAce(PACL Acl,
if (!RtlValidSid(Sid)) if (!RtlValidSid(Sid))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_INVALID_SID);
} }
if (Acl->AclRevision > 3 || if (Acl->AclRevision > 3 ||
Revision > 3) Revision > 3)
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNKNOWN_REVISION);
} }
if (Revision < Acl->AclRevision) if (Revision < Acl->AclRevision)
{ {
@ -118,7 +118,7 @@ RtlpAddKnownAce(PACL Acl,
} }
if (!RtlFirstFreeAce(Acl, &Ace)) if (!RtlFirstFreeAce(Acl, &Ace))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_BUFFER_TOO_SMALL);
} }
if (Ace == NULL) if (Ace == NULL)
{ {
@ -127,13 +127,13 @@ RtlpAddKnownAce(PACL Acl,
if (((PVOID)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >= if (((PVOID)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >=
((PVOID)Acl + Acl->AclSize)) ((PVOID)Acl + Acl->AclSize))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_BUFFER_TOO_SMALL);
} }
Ace->Header.AceFlags = 0; Ace->Header.AceFlags = 0;
Ace->Header.AceType = Type; Ace->Header.AceType = Type;
Ace->Header.AceSize = RtlLengthSid(Sid) + sizeof(ACE); Ace->Header.AceSize = RtlLengthSid(Sid) + sizeof(ACE);
Ace->Header.AccessMask = AccessMask; Ace->Header.AccessMask = AccessMask;
RtlCopySid(RtlLengthSid(Sid), (PSID)Ace + 1, Sid); RtlCopySid(RtlLengthSid(Sid), (PSID)(Ace + 1), Sid);
Acl->AceCount++; Acl->AceCount++;
Acl->AclRevision = Revision; Acl->AclRevision = Revision;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);

View file

@ -1,4 +1,4 @@
/* $Id: acl.c,v 1.6 2002/06/07 22:59:42 ekohl Exp $ /* $Id: acl.c,v 1.7 2002/06/15 10:09:17 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -179,42 +179,42 @@ RtlpAddKnownAce(PACL Acl,
PSID Sid, PSID Sid,
ULONG Type) ULONG Type)
{ {
PACE Ace; PACE Ace;
if (!RtlValidSid(Sid)) if (!RtlValidSid(Sid))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_INVALID_SID);
} }
if (Acl->AclRevision > 3 || if (Acl->AclRevision > 3 ||
Revision > 3) Revision > 3)
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNKNOWN_REVISION);
} }
if (Revision < Acl->AclRevision) if (Revision < Acl->AclRevision)
{ {
Revision = Acl->AclRevision; Revision = Acl->AclRevision;
} }
if (!RtlFirstFreeAce(Acl, &Ace)) if (!RtlFirstFreeAce(Acl, &Ace))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_BUFFER_TOO_SMALL);
} }
if (Ace == NULL) if (Ace == NULL)
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
if (((PVOID)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >= if (((PVOID)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >=
((PVOID)Acl + Acl->AclSize)) ((PVOID)Acl + Acl->AclSize))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_BUFFER_TOO_SMALL);
} }
Ace->Header.AceFlags = 0; Ace->Header.AceFlags = 0;
Ace->Header.AceType = Type; Ace->Header.AceType = Type;
Ace->Header.AceSize = RtlLengthSid(Sid) + sizeof(ACE); Ace->Header.AceSize = RtlLengthSid(Sid) + sizeof(ACE);
Ace->Header.AccessMask = AccessMask; Ace->Header.AccessMask = AccessMask;
RtlCopySid(RtlLengthSid(Sid), (PSID)Ace + 1, Sid); RtlCopySid(RtlLengthSid(Sid), (PSID)(Ace + 1), Sid);
Acl->AceCount++; Acl->AceCount++;
Acl->AclRevision = Revision; Acl->AclRevision = Revision;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -224,7 +224,7 @@ RtlAddAccessAllowedAce(PACL Acl,
ACCESS_MASK AccessMask, ACCESS_MASK AccessMask,
PSID Sid) PSID Sid)
{ {
return(RtlpAddKnownAce(Acl, Revision, AccessMask, Sid, 0)); return(RtlpAddKnownAce(Acl, Revision, AccessMask, Sid, 0));
} }
@ -300,26 +300,26 @@ RtlCreateAcl(PACL Acl,
ULONG AclSize, ULONG AclSize,
ULONG AclRevision) ULONG AclRevision)
{ {
if (AclSize < 8) if (AclSize < 8)
{ {
return(STATUS_BUFFER_TOO_SMALL); return(STATUS_BUFFER_TOO_SMALL);
} }
if (AclRevision != 2 && if (AclRevision != 2 &&
AclRevision != 3) AclRevision != 3)
{ {
return(STATUS_UNKNOWN_REVISION); return(STATUS_UNKNOWN_REVISION);
} }
if (AclSize > 0xffff) if (AclSize > 0xffff)
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
AclSize = AclSize & ~(0x3); AclSize = AclSize & ~(0x3);
Acl->AclSize = AclSize; Acl->AclSize = AclSize;
Acl->AclRevision = AclRevision; Acl->AclRevision = AclRevision;
Acl->AceCount = 0; Acl->AceCount = 0;
Acl->Sbz1 = 0; Acl->Sbz1 = 0;
Acl->Sbz2 = 0; Acl->Sbz2 = 0;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* EOF */ /* EOF */