Author: tkreuzer
Date: Tue Nov  4 20:41:10 2014
New Revision: 65254

URL: http://svn.reactos.org/svn/reactos?rev=65254&view=rev
Log:
[NTOSKRNL]
Merge r62304 and r65253 from kernel-fun branch:
Fix logic in ObSetSecurityDescriptorInfo. To understand the change: it is not 
only style change! The old code modified SecurityDescriptor, which must always 
stay the same in the loop!

Modified:
    trunk/reactos/   (props changed)
    trunk/reactos/ntoskrnl/ob/obsecure.c

Propchange: trunk/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo       (original)
+++ svn:mergeinfo       Tue Nov  4 20:41:10 2014
@@ -6,6 +6,7 @@
 /branches/condrv_restructure:63104-64101
 /branches/header-work:45691-47721
 /branches/kd++:58883-58973
+/branches/kernel-fun/reactos:62304,65253
 /branches/ntvdm:59241-63176
 /branches/reactos-yarotows:45219-46371,46373-48025,48027-49273
 /branches/reactx/reactos:49994-49995

Modified: trunk/reactos/ntoskrnl/ob/obsecure.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obsecure.c?rev=65254&r1=65253&r2=65254&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obsecure.c        [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ob/obsecure.c        [iso-8859-1] Tue Nov  4 
20:41:10 2014
@@ -144,60 +144,53 @@
                                              &NewDescriptor,
                                              PoolType,
                                              GenericMapping);
-        if (NT_SUCCESS(Status))
-        {
-            /* Now add this to the cache */
-            Status = ObLogSecurityDescriptor(NewDescriptor,
-                                             &CachedDescriptor,
-                                             MAX_FAST_REFS + 1);
-
-            /* Let go of our uncached copy */
-            ExFreePool(NewDescriptor);
-
-            /* Check for success */
-            if (NT_SUCCESS(Status))
-            {
-                /* Do the swap */
-                FastRef = (PEX_FAST_REF)OutputSecurityDescriptor;
-                OldValue = ExCompareSwapFastReference(FastRef,
-                                                      CachedDescriptor,
-                                                      OldDescriptor);
-
-                /* Get the security descriptor */
-                SecurityDescriptor = ExGetObjectFastReference(OldValue);
-                Count = ExGetCountFastReference(OldValue);
-
-                /* Make sure the swap worked */
-                if (SecurityDescriptor == OldDescriptor)
-                {
-                    /* Flush waiters */
-                    ObpAcquireObjectLock(ObjectHeader);
-                    ObpReleaseObjectLock(ObjectHeader);
-
-                    /* And dereference the old one */
-                    ObDereferenceSecurityDescriptor(OldDescriptor, Count + 2);
-                    break;
-                }
-                else
-                {
-                    /* Someone changed it behind our back -- try again */
-                    ObDereferenceSecurityDescriptor(OldDescriptor, 1);
-                    ObDereferenceSecurityDescriptor(CachedDescriptor,
-                                                    MAX_FAST_REFS + 1);
-                }
-            }
-            else
-            {
-                /* We failed, dereference the old one */
-                ObDereferenceSecurityDescriptor(OldDescriptor, 1);
-                break;
-            }
-        }
-        else
+        if (!NT_SUCCESS(Status))
         {
             /* We failed, dereference the old one */
             if (OldDescriptor) ObDereferenceSecurityDescriptor(OldDescriptor, 
1);
             break;
+        }
+
+        /* Now add this to the cache */
+        Status = ObLogSecurityDescriptor(NewDescriptor,
+                                         &CachedDescriptor,
+                                         MAX_FAST_REFS + 1);
+
+        /* Let go of our uncached copy */
+        ExFreePool(NewDescriptor);
+
+        /* Check for success */
+        if (!NT_SUCCESS(Status))
+        {
+            /* We failed, dereference the old one */
+            ObDereferenceSecurityDescriptor(OldDescriptor, 1);
+            break;
+        }
+
+        /* Do the swap */
+        FastRef = (PEX_FAST_REF)OutputSecurityDescriptor;
+        OldValue = ExCompareSwapFastReference(FastRef,
+                                              CachedDescriptor,
+                                              OldDescriptor);
+
+        /* Make sure the swap worked */
+        if (ExGetObjectFastReference(OldValue) == OldDescriptor)
+        {
+            /* Flush waiters */
+            ObpAcquireObjectLock(ObjectHeader);
+            ObpReleaseObjectLock(ObjectHeader);
+
+            /* And dereference the old one */
+            Count = ExGetCountFastReference(OldValue);
+            ObDereferenceSecurityDescriptor(OldDescriptor, Count + 2);
+            break;
+        }
+        else
+        {
+            /* Someone changed it behind our back -- try again */
+            ObDereferenceSecurityDescriptor(OldDescriptor, 1);
+            ObDereferenceSecurityDescriptor(CachedDescriptor,
+                                            MAX_FAST_REFS + 1);
         }
     }
 


Reply via email to