From b637046c9d155d832fcab1892bc2999ffe1ad8a8 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 11 Dec 2013 11:42:44 +0000 Subject: [PATCH] [FASTFAT] Fail, if we try to overwrite an eixting read-only file. svn path=/trunk/; revision=61260 --- reactos/drivers/filesystems/fastfat/create.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/reactos/drivers/filesystems/fastfat/create.c b/reactos/drivers/filesystems/fastfat/create.c index 70924a5882e..04d0c0d3452 100644 --- a/reactos/drivers/filesystems/fastfat/create.c +++ b/reactos/drivers/filesystems/fastfat/create.c @@ -349,6 +349,7 @@ VfatOpenFile( PDEVICE_EXTENSION DeviceExt, PUNICODE_STRING PathNameU, PFILE_OBJECT FileObject, + ULONG RequestedDisposition, PVFATFCB *ParentFcb) { PVFATFCB Fcb; @@ -404,6 +405,15 @@ VfatOpenFile( vfatReleaseFCB (DeviceExt, Fcb); return STATUS_DELETE_PENDING; } + + /* Fail, if we try to overwrite a read-only file */ + if ((*Fcb->Attributes & FILE_ATTRIBUTE_READONLY) && + (RequestedDisposition == FILE_OVERWRITE)) + { + vfatReleaseFCB(DeviceExt, Fcb); + return STATUS_ACCESS_DENIED; + } + DPRINT("Attaching FCB to fileObject\n"); Status = vfatAttachFCBToFileObject(DeviceExt, Fcb, FileObject); if (!NT_SUCCESS(Status)) @@ -519,7 +529,7 @@ VfatCreateFile( } /* Try opening the file. */ - Status = VfatOpenFile(DeviceExt, &PathNameU, FileObject, &ParentFcb); + Status = VfatOpenFile(DeviceExt, &PathNameU, FileObject, RequestedDisposition, &ParentFcb); /* * If the directory containing the file to open doesn't exist then