Author: tfaber
Date: Sun Aug 24 03:28:01 2014
New Revision: 63928
URL:
http://svn.reactos.org/svn/reactos?rev=63928&view=rev
Log:
[FASTFAT]
- Properly handle errors in CcInitializeCacheMap, CcCopyRead and CcCopyWrite
CORE-8410
Modified:
trunk/reactos/drivers/filesystems/fastfat/CMakeLists.txt
trunk/reactos/drivers/filesystems/fastfat/fcb.c
trunk/reactos/drivers/filesystems/fastfat/fsctl.c
trunk/reactos/drivers/filesystems/fastfat/rw.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
Modified: trunk/reactos/drivers/filesystems/fastfat/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/CMakeLists.txt [iso-8859-1] Sun Aug 24
03:28:01 2014
@@ -26,6 +26,7 @@
add_library(fastfat SHARED ${SOURCE} vfatfs.rc)
set_module_type(fastfat kernelmodedriver)
+target_link_libraries(fastfat ${PSEH_LIB})
add_importlibs(fastfat ntoskrnl hal)
add_pch(fastfat vfat.h SOURCE)
Modified: trunk/reactos/drivers/filesystems/fastfat/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] Sun Aug 24 03:28:01 2014
@@ -340,12 +340,14 @@
{
PFILE_OBJECT fileObject;
PVFATCCB newCCB;
+ NTSTATUS status;
fileObject = IoCreateStreamFileObject (NULL, vcb->StorageDevice);
newCCB =
ExAllocateFromNPagedLookasideList(&VfatGlobalData->CcbLookasideList);
if (newCCB == NULL)
{
+ ObDereferenceObject(fileObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(newCCB, sizeof (VFATCCB));
@@ -356,11 +358,24 @@
fcb->FileObject = fileObject;
fcb->RefCount++;
- CcInitializeCacheMap(fileObject,
- (PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
- TRUE,
- &VfatGlobalData->CacheMgrCallbacks,
- fcb);
+ _SEH2_TRY
+ {
+ CcInitializeCacheMap(fileObject,
+ (PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
+ TRUE,
+ &VfatGlobalData->CacheMgrCallbacks,
+ fcb);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ status = _SEH2_GetExceptionCode();
+ fcb->RefCount--;
+ fcb->FileObject = NULL;
+ ExFreeToNPagedLookasideList(&VfatGlobalData->CcbLookasideList, newCCB);
+ ObDereferenceObject(fileObject);
+ return status;
+ }
+ _SEH2_END;
fcb->Flags |= FCB_CACHE_INITIALIZED;
return STATUS_SUCCESS;
Modified: trunk/reactos/drivers/filesystems/fastfat/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] Sun Aug 24 03:28:01
2014
@@ -550,11 +550,20 @@
Fcb->RFCB.ValidDataLength = Fcb->RFCB.FileSize;
Fcb->RFCB.AllocationSize = Fcb->RFCB.FileSize;
- CcInitializeCacheMap(DeviceExt->FATFileObject,
- (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
- TRUE,
- &VfatGlobalData->CacheMgrCallbacks,
- Fcb);
+ _SEH2_TRY
+ {
+ CcInitializeCacheMap(DeviceExt->FATFileObject,
+ (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
+ TRUE,
+ &VfatGlobalData->CacheMgrCallbacks,
+ Fcb);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ goto ByeBye;
+ }
+ _SEH2_END;
DeviceExt->LastAvailableCluster = 2;
ExInitializeResourceLite(&DeviceExt->FatResource);
Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] Sun Aug 24 03:28:01 2014
@@ -673,22 +673,35 @@
Status = /*STATUS_END_OF_FILE*/STATUS_SUCCESS;
}
- if (IrpContext->FileObject->PrivateCacheMap == NULL)
- {
- CcInitializeCacheMap(IrpContext->FileObject,
- (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
- FALSE,
- &(VfatGlobalData->CacheMgrCallbacks),
- Fcb);
- }
-
- if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
- (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT),
Buffer,
- &IrpContext->Irp->IoStatus))
- {
- Status = STATUS_PENDING;
- goto ByeBye;
- }
+ _SEH2_TRY
+ {
+ if (IrpContext->FileObject->PrivateCacheMap == NULL)
+ {
+ CcInitializeCacheMap(IrpContext->FileObject,
+ (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
+ FALSE,
+ &(VfatGlobalData->CacheMgrCallbacks),
+ Fcb);
+ }
+
+ if (!CcCopyRead(IrpContext->FileObject,
+ &ByteOffset,
+ Length,
+ (IrpContext->Flags & IRPCONTEXT_CANWAIT) != 0,
+ Buffer,
+ &IrpContext->Irp->IoStatus))
+ {
+ ASSERT((IrpContext->Flags & IRPCONTEXT_CANWAIT) == 0);
+ Status = STATUS_PENDING;
+ goto ByeBye;
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ goto ByeBye;
+ }
+ _SEH2_END;
if (!NT_SUCCESS(IrpContext->Irp->IoStatus.Status))
{
@@ -947,30 +960,42 @@
{
// cached write
- if (IrpContext->FileObject->PrivateCacheMap == NULL)
- {
- CcInitializeCacheMap(IrpContext->FileObject,
- (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
- FALSE,
- &VfatGlobalData->CacheMgrCallbacks,
- Fcb);
- }
-
- if (ByteOffset.QuadPart > OldFileSize.QuadPart)
- {
- CcZeroData(IrpContext->FileObject, &OldFileSize, &ByteOffset,
TRUE);
- }
-
- if (CcCopyWrite(IrpContext->FileObject, &ByteOffset, Length,
- 1 /*IrpContext->Flags & IRPCONTEXT_CANWAIT*/, Buffer))
- {
- IrpContext->Irp->IoStatus.Information = Length;
- Status = STATUS_SUCCESS;
- }
- else
- {
- Status = STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ if (IrpContext->FileObject->PrivateCacheMap == NULL)
+ {
+ CcInitializeCacheMap(IrpContext->FileObject,
+ (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
+ FALSE,
+ &VfatGlobalData->CacheMgrCallbacks,
+ Fcb);
+ }
+
+ if (ByteOffset.QuadPart > OldFileSize.QuadPart)
+ {
+ CcZeroData(IrpContext->FileObject, &OldFileSize, &ByteOffset,
TRUE);
+ }
+
+ if (CcCopyWrite(IrpContext->FileObject,
+ &ByteOffset,
+ Length,
+ TRUE /*(IrpContext->Flags & IRPCONTEXT_CANWAIT) !=
0*/,
+ Buffer))
+ {
+ IrpContext->Irp->IoStatus.Information = Length;
+ Status = STATUS_SUCCESS;
+ }
+ else
+ {
+ ASSERT(FALSE /*(IrpContext->Flags & IRPCONTEXT_CANWAIT) == 0*/);
+ Status = STATUS_UNSUCCESSFUL;
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
}
else
{
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Sun Aug 24 03:28:01
2014
@@ -4,6 +4,7 @@
#include <ntifs.h>
#include <ntdddisk.h>
#include <dos.h>
+#include <pseh/pseh2.h>
#define USE_ROS_CC_AND_FS