From 2ac2acf2d744aca0ae427d9931b6767a010de47f Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 20 Sep 2017 08:45:28 +0000 Subject: [PATCH] [VFATLIB] Fix a really bad bug in VfatChkdsk(), the routine used to check a volume: In case readwrite is enabled (ie, volume fixing is allowed), when the volume is opened, it is also locked. If the volume has the clean shutdown bit and is to be checked only if that one is not set, then the volume lock is leaked. This makes the volume then totally unusable later on (any later open will fail). Because r75772 fixed volume locking on non-system partition, this totally broke (access denied) any secondary FAT volume in ROS. Now, we just properly release the lock when required, also made a comment more explicit to avoid later bugs like that. CORE-13805 svn path=/trunk/; revision=75911 --- reactos/sdk/lib/fslib/vfatlib/vfatlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reactos/sdk/lib/fslib/vfatlib/vfatlib.c b/reactos/sdk/lib/fslib/vfatlib/vfatlib.c index d61b35958c5..267d3a12751 100644 --- a/reactos/sdk/lib/fslib/vfatlib/vfatlib.c +++ b/reactos/sdk/lib/fslib/vfatlib/vfatlib.c @@ -402,11 +402,15 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot, verify = TRUE; salvage_files = TRUE; - /* Open filesystem */ + /* Open filesystem and lock it */ fs_open(DriveRoot, FsCheckFlags & FSCHECK_READ_WRITE); if (CheckOnlyIfDirty && !fs_isdirty()) { + /* Unlock volume if required */ + if (FsCheckFlags & FSCHECK_READ_WRITE) + fs_lock(FALSE); + /* No need to check FS */ return (fs_close(FALSE) == 0 ? STATUS_SUCCESS : STATUS_DISK_CORRUPT_ERROR); } -- 2.17.1