https://git.reactos.org/?p=reactos.git;a=commitdiff;h=18d6584da443c23b1b139…
commit 18d6584da443c23b1b139d6995007781b495e868
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Dec 9 21:22:55 2017 +0100
[FASTFAT] Fix FastFAT not returning short name for FAT volumes in FileBothDirectoryInformation case
This is likely due to a copy paste error where long name was copied twice and short never.
Fun fact: this was not affecting FATX volumes
Fun fact2: this was defeating a buffer overflow check and thus was allowing buffer overflow!
CORE-14088
---
drivers/filesystems/fastfat/dir.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/filesystems/fastfat/dir.c b/drivers/filesystems/fastfat/dir.c
index 51359c4966..dd53080cda 100644
--- a/drivers/filesystems/fastfat/dir.c
+++ b/drivers/filesystems/fastfat/dir.c
@@ -427,9 +427,10 @@ VfatGetFileBothInformation(
{
pInfo->ShortNameLength = (CCHAR)DirContext->ShortNameU.Length;
- RtlCopyMemory(pInfo->FileName,
- DirContext->LongNameU.Buffer,
- DirContext->LongNameU.Length);
+ ASSERT(pInfo->ShortNameLength / sizeof(WCHAR) <= 12);
+ RtlCopyMemory(pInfo->ShortName,
+ DirContext->ShortNameU.Buffer,
+ DirContext->ShortNameU.Length);
/* pInfo->FileIndex = ; */
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=48250aef6e1fbc00822b3…
commit 48250aef6e1fbc00822b338322f8d5fe050fe138
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Dec 9 21:10:32 2017 +0100
[CHKDSK] Don't continue repair if volume is in use
This makes use of previous commit vfatlib improvements that allow
caller to stop chkdsk if locking fail, which will happen if volume is in use.
That way, ReactOS users won't be able any longer to f*** up their C:\ volume
by attempting to chkdsk -f it!
CORE-14087
---
base/system/chkdsk/chkdsk.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/base/system/chkdsk/chkdsk.c b/base/system/chkdsk/chkdsk.c
index 57a7b26aef..76dc975098 100644
--- a/base/system/chkdsk/chkdsk.c
+++ b/base/system/chkdsk/chkdsk.c
@@ -228,6 +228,7 @@ ChkdskCallback(
DWORD Modifier,
PVOID Argument)
{
+ BOOLEAN Ret;
PDWORD percent;
PBOOLEAN status;
PTEXTOUTPUT output;
@@ -236,6 +237,7 @@ ChkdskCallback(
// We get other types of commands,
// but we don't have to pay attention to them
//
+ Ret = TRUE;
switch (Command)
{
case UNKNOWN2:
@@ -259,7 +261,8 @@ ChkdskCallback(
break;
case VOLUMEINUSE:
- ConPuts(StdOut, L"VOLUMEINUSE\n");
+ ConPuts(StdOut, L"Volume is in use and cannot be locked\n");
+ Ret = FALSE;
break;
case UNKNOWN9:
@@ -313,7 +316,7 @@ ChkdskCallback(
}
break;
}
- return TRUE;
+ return Ret;
}
#ifndef FMIFS_IMPORT_DLL
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6a224a38a15bd3b02ce3b…
commit 6a224a38a15bd3b02ce3b20eef3a3f2ccf68ab96
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Dec 9 21:07:09 2017 +0100
[VFATLIB] Make Chkdsk handle volume opening locking failures.
For instance, when repair is required, we can ask the caller whether we should
continue or not in case locking failed.
Also, introduced a hack for 1st stage where IopParseDevice() hack is in usage
so that broken NTSTATUS is diverted to appropriate status.
That way, usetup will properly continue even if locking failed (due to its
callback stub!)
CORE-14087
---
sdk/lib/fslib/vfatlib/check/io.c | 18 +++++++++++++++---
sdk/lib/fslib/vfatlib/check/io.h | 2 +-
sdk/lib/fslib/vfatlib/vfatlib.c | 16 +++++++++++++++-
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/sdk/lib/fslib/vfatlib/check/io.c b/sdk/lib/fslib/vfatlib/check/io.c
index 17db7a1c8e..2eca2abdd4 100644
--- a/sdk/lib/fslib/vfatlib/check/io.c
+++ b/sdk/lib/fslib/vfatlib/check/io.c
@@ -159,7 +159,7 @@ static off_t WIN32lseek(HANDLE fd, off_t offset, int whence)
/******************************************************************************/
-void fs_open(PUNICODE_STRING DriveRoot, int read_write)
+NTSTATUS fs_open(PUNICODE_STRING DriveRoot, int read_write)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -180,11 +180,14 @@ void fs_open(PUNICODE_STRING DriveRoot, int read_write)
if (!NT_SUCCESS(Status))
{
DPRINT1("NtOpenFile() failed with status 0x%.08x\n", Status);
- return;
+ return Status;
}
// If read_write is specified, then the volume should be exclusively locked
- if (read_write) fs_lock(TRUE);
+ if (read_write)
+ {
+ Status = fs_lock(TRUE);
+ }
// Query geometry and partition info, to have bytes per sector, etc
@@ -192,6 +195,8 @@ void fs_open(PUNICODE_STRING DriveRoot, int read_write)
changes = last = NULL;
did_change = 0;
+
+ return Status;
}
BOOLEAN fs_isdirty(void)
@@ -231,6 +236,13 @@ NTSTATUS fs_lock(BOOLEAN LockVolume)
if (!NT_SUCCESS(Status))
{
DPRINT1("NtFsControlFile() failed with Status 0x%08x\n", Status);
+#if 1
+ /* FIXME: ReactOS HACK for 1stage due to IopParseDevice() hack */
+ if (Status == STATUS_INVALID_DEVICE_REQUEST)
+ {
+ Status = STATUS_ACCESS_DENIED;
+ }
+#endif
}
return Status;
diff --git a/sdk/lib/fslib/vfatlib/check/io.h b/sdk/lib/fslib/vfatlib/check/io.h
index 1178cd1e5b..23c6fd6a71 100644
--- a/sdk/lib/fslib/vfatlib/check/io.h
+++ b/sdk/lib/fslib/vfatlib/check/io.h
@@ -34,7 +34,7 @@
//#include <sys/types.h> /* for loff_t */
// #include <fcntl.h> /* for off_t */
-void fs_open(PUNICODE_STRING DriveRoot, int read_write);
+NTSTATUS fs_open(PUNICODE_STRING DriveRoot, int read_write);
/* Opens the file system PATH. If RW is zero, the file system is opened
read-only, otherwise, it is opened read-write. */
diff --git a/sdk/lib/fslib/vfatlib/vfatlib.c b/sdk/lib/fslib/vfatlib/vfatlib.c
index 267d3a1275..8db6e8a11a 100644
--- a/sdk/lib/fslib/vfatlib/vfatlib.c
+++ b/sdk/lib/fslib/vfatlib/vfatlib.c
@@ -383,6 +383,7 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot,
BOOLEAN salvage_files;
ULONG free_clusters;
DOS_FS fs;
+ NTSTATUS Status;
RtlZeroMemory(&fs, sizeof(fs));
@@ -403,7 +404,20 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot,
salvage_files = TRUE;
/* Open filesystem and lock it */
- fs_open(DriveRoot, FsCheckFlags & FSCHECK_READ_WRITE);
+ Status = fs_open(DriveRoot, FsCheckFlags & FSCHECK_READ_WRITE);
+ if (Status == STATUS_ACCESS_DENIED)
+ {
+ /* We failed to lock, ask the caller whether we should continue */
+ if (Callback(VOLUMEINUSE, 0, NULL))
+ {
+ Status = STATUS_SUCCESS;
+ }
+ }
+ if (!NT_SUCCESS(Status))
+ {
+ fs_close(FALSE);
+ return STATUS_DISK_CORRUPT_ERROR;
+ }
if (CheckOnlyIfDirty && !fs_isdirty())
{