Windows: AFSDeleteDirEntry deleted flag shuffle
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 26 Mar 2013 12:59:14 +0000 (08:59 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 6 Apr 2013 02:25:37 +0000 (19:25 -0700)
Move the assignment of the deleted flag earlier in AFSDeleteDirEntry()
to avoid potential invalid memory access.

Change-Id: I6d0e1272cc9f2bb491ad291a65b94c53ced9a354
Reviewed-on: http://gerrit.openafs.org/9672
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp

index 376ca2d..8930dd1 100644 (file)
@@ -2797,6 +2797,13 @@ AFSDeleteDirEntry( IN AFSObjectInfoCB *ParentObjectInfo,
             AFSExFreePoolWithTag( DirEntry->NameInformation.TargetName.Buffer, 0);
         }
 
+        if( BooleanFlagOn( DirEntry->Flags, AFS_DIR_ENTRY_DELETED) &&
+            DirEntry->ObjectInformation->Links == 0)
+        {
+
+            SetFlag( DirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DELETED);
+        }
+
         //
         // Dereference the object for this dir entry
         //
@@ -2810,13 +2817,6 @@ AFSDeleteDirEntry( IN AFSObjectInfoCB *ParentObjectInfo,
                       DirEntry->ObjectInformation,
                       lCount));
 
-        if( BooleanFlagOn( DirEntry->Flags, AFS_DIR_ENTRY_DELETED) &&
-            DirEntry->ObjectInformation->Links == 0)
-        {
-
-            SetFlag( DirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DELETED);
-        }
-
         ExDeleteResourceLite( &DirEntry->NonPaged->Lock);
 
         AFSExFreePoolWithTag( DirEntry->NonPaged, AFS_DIR_ENTRY_NP_TAG);