update for HEAD-2003050101
[reactos.git] / ntoskrnl / se / acl.c
index bd24958..dd4ca43 100644 (file)
@@ -134,41 +134,45 @@ BOOLEAN STDCALL
 RtlFirstFreeAce(PACL Acl,
                PACE* Ace)
 {
-   PACE Current;
-   PVOID AclEnd;
-   ULONG i;
+  PACE Current;
+  PVOID AclEnd;
+  ULONG i;
+
+  Current = (PACE)(Acl + 1);
+  *Ace = NULL;
+  i = 0;
+  if (Acl->AceCount == 0)
+    {
+      *Ace = Current;
+      return(TRUE);
+    }
 
-   Current = (PACE)(Acl + 1);
-   *Ace = NULL;
-   i = 0;
-   if (Acl->AceCount == 0)
-     {
-       *Ace = Current;
-       return(TRUE);
-     }
-   AclEnd = Acl->AclSize + Acl;
-   do
-     {
-       if ((PVOID)Current >= AclEnd)
-         {
-            return(FALSE);
-         }
-       if (Current->Header.AceType == 4)
-         {
-            if (Acl->AclRevision < 3)
-              {
-                 return(FALSE);
-              }
-         }
-       Current = (PACE)((PVOID)Current + (ULONG)Current->Header.AceSize);
-       i++;
-     } while (i < Acl->AceCount);
-   if ((PVOID)Current >= AclEnd)
-     {
-       return(FALSE);
-     }
-   *Ace = Current;
-   return(TRUE);
+  AclEnd = Acl->AclSize + (PVOID)Acl;
+  do
+    {
+      if ((PVOID)Current >= AclEnd)
+       {
+         return(FALSE);
+       }
+
+      if (Current->Header.AceType == 4)
+       {
+         if (Acl->AclRevision < 3)
+           {
+             return(FALSE);
+           }
+       }
+      Current = (PACE)((PVOID)Current + (ULONG)Current->Header.AceSize);
+      i++;
+    }
+  while (i < Acl->AceCount);
+
+  if ((PVOID)Current < AclEnd)
+    {
+      *Ace = Current;
+    }
+
+  return(TRUE);
 }
 
 
@@ -322,4 +326,27 @@ RtlCreateAcl(PACL Acl,
   return(STATUS_SUCCESS);
 }
 
+
+BOOLEAN STDCALL
+RtlValidAcl(PACL Acl)
+{
+  PACE Ace;
+  USHORT Size;
+
+  Size = (Acl->AclSize + 3) & ~3;
+
+  if (Acl->AclRevision != 2 &&
+      Acl->AclRevision != 3)
+    {
+      return(FALSE);
+    }
+
+  if (Size != Acl->AclSize)
+    {
+      return(FALSE);
+    }
+
+  return(RtlFirstFreeAce(Acl, &Ace));
+}
+
 /* EOF */