https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f3fecf92c1033a747b048…
commit f3fecf92c1033a747b04828de974444c1013dc8f
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Mon Jan 1 12:12:08 2018 +0100
[FASTFAT] On file overwrite, deny it if file as HIDDEN/SYSTEM flag and caller
doesn't set them.
CORE-14158
---
drivers/filesystems/fastfat/create.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/filesystems/fastfat/create.c b/drivers/filesystems/fastfat/create.c
index 20a4bc0d04..89ac5e07c4 100644
--- a/drivers/filesystems/fastfat/create.c
+++ b/drivers/filesystems/fastfat/create.c
@@ -728,6 +728,8 @@ VfatCreateFile(
return Status;
}
+ Attributes = Stack->Parameters.Create.FileAttributes &
~FILE_ATTRIBUTE_NORMAL;
+
/* If the file open failed then create the required file */
if (!NT_SUCCESS (Status))
{
@@ -736,7 +738,6 @@ VfatCreateFile(
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE)
{
- Attributes = Stack->Parameters.Create.FileAttributes &
~FILE_ATTRIBUTE_NORMAL;
if (!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
{
if (TrailingBackslash)
@@ -908,9 +909,17 @@ VfatCreateFile(
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE)
{
+ if ((BooleanFlagOn(*pFcb->Attributes, FILE_ATTRIBUTE_HIDDEN) &&
!BooleanFlagOn(Attributes, FILE_ATTRIBUTE_HIDDEN)) ||
+ (BooleanFlagOn(*pFcb->Attributes, FILE_ATTRIBUTE_SYSTEM) &&
!BooleanFlagOn(Attributes, FILE_ATTRIBUTE_SYSTEM)))
+ {
+ VfatCloseFile(DeviceExt, FileObject);
+ vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
+ return STATUS_ACCESS_DENIED;
+ }
+
if (!vfatFCBIsDirectory(pFcb))
{
- *pFcb->Attributes = Stack->Parameters.Create.FileAttributes &
~FILE_ATTRIBUTE_NORMAL;
+ *pFcb->Attributes = Attributes & ~FILE_ATTRIBUTE_NORMAL;
*pFcb->Attributes |= FILE_ATTRIBUTE_ARCHIVE;
VfatUpdateEntry(pFcb, vfatVolumeIsFatX(DeviceExt));
}