Author: ion
Date: Fri Jul 7 21:29:12 2006
New Revision: 22904
URL:
http://svn.reactos.org/svn/reactos?rev=22904&view=rev
Log:
- Make an I/O Tagged copy of the file name and properly handle failure.
Modified:
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/include/internal/tag.h
trunk/reactos/ntoskrnl/io/iomgr/file.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h Fri Jul 7 21:29:12 2006
@@ -612,6 +612,12 @@
VOID
NTAPI
+IopDereferenceVpb(
+ IN PVPB Vpb
+);
+
+VOID
+NTAPI
IoInitFileSystemImplementation(
VOID
);
Modified: trunk/reactos/ntoskrnl/include/internal/tag.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/tag.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/tag.h Fri Jul 7 21:29:12 2006
@@ -53,6 +53,7 @@
#define TAG_IO TAG('I', 'o', ' ', ' ')
#define TAG_ERROR_LOG TAG('I', 'o', 'E', 'r')
#define TAG_EA TAG('I', 'o', 'E', 'a')
+#define TAG_IO_NAME TAG('I', 'o', 'N', 'm')
/* formerly located in io/work.c */
#define TAG_IOWI TAG('I', 'O', 'W', 'I')
Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/file.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/file.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/file.c Fri Jul 7 21:29:12 2006
@@ -33,7 +33,7 @@
PDEVICE_OBJECT OriginalDeviceObject = (PDEVICE_OBJECT)ParseObject, DeviceObject;
NTSTATUS Status;
PFILE_OBJECT FileObject;
- PVPB Vpb;
+ PVPB Vpb = NULL;
PIRP Irp;
PEXTENDED_IO_STACK_LOCATION StackLoc;
IO_SECURITY_CONTEXT SecurityContext;
@@ -141,9 +141,6 @@
(PVOID*)&FileObject);
RtlZeroMemory(FileObject, sizeof(FILE_OBJECT));
- /* Create the name for the file object */
- RtlCreateUnicodeString(&FileObject->FileName, RemainingName->Buffer);
-
/* Set the device object and reference it */
Status = IopReferenceDeviceObject(DeviceObject);
FileObject->DeviceObject = DeviceObject;
@@ -248,6 +245,33 @@
StackLoc->Parameters.Create.FileAttributes = OpenPacket->FileAttributes;
StackLoc->Parameters.Create.ShareAccess = OpenPacket->ShareAccess;
StackLoc->Parameters.Create.SecurityContext = &SecurityContext;
+
+ /* Check if the file object has a name */
+ if (RemainingName->Length)
+ {
+ /* Setup the unicode string */
+ FileObject->FileName.MaximumLength = RemainingName->Length;
+ FileObject->FileName.Buffer = ExAllocatePoolWithTag(PagedPool,
+ RemainingName->
+ Length,
+ TAG_IO_NAME);
+ if (!FileObject->FileName.Buffer)
+ {
+ /* Failed to allocate the name, free the IRP */
+ IoFreeIrp(Irp);
+
+ /* Dereference the device object and VPB */
+ IopDereferenceDeviceObject(DeviceObject, FALSE);
+ if (Vpb) IopDereferenceVpb(Vpb);
+
+ /* Clear the FO */
+ FileObject->DeviceObject = NULL;
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
+
+ /* Copy the name */
+ RtlCopyUnicodeString(&FileObject->FileName, RemainingName);
/* Reference the file object and call the driver */
ObReferenceObject(FileObject);