[NTFS]
authorPierre Schweitzer <pierre@reactos.org>
Tue, 26 May 2015 07:10:45 +0000 (07:10 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Tue, 26 May 2015 07:10:45 +0000 (07:10 +0000)
- Don't attempt to moon walk path name for reserved MFT entries.
- Don't attempt to dereference file name if it doesn't exist

svn path=/trunk/; revision=67918

reactos/drivers/filesystems/ntfs/create.c

index 1db8d1d..a71c507 100644 (file)
@@ -98,8 +98,6 @@ NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt,
 
     DPRINT1("NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt, Id, OutPath);
 
 
     DPRINT1("NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt, Id, OutPath);
 
-    Id = Id & NTFS_MFT_MASK;
-
     RtlZeroMemory(FullPath, sizeof(FullPath));
     MftRecord = ExAllocatePoolWithTag(NonPagedPool,
                                       DeviceExt->NtfsInfo.BytesPerFileRecord,
     RtlZeroMemory(FullPath, sizeof(FullPath));
     MftRecord = ExAllocatePoolWithTag(NonPagedPool,
                                       DeviceExt->NtfsInfo.BytesPerFileRecord,
@@ -123,6 +121,13 @@ NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt,
         }
 
         FileName = GetBestFileNameFromRecord(MftRecord);
         }
 
         FileName = GetBestFileNameFromRecord(MftRecord);
+        if (FileName == NULL)
+        {
+            DPRINT1("$FILE_NAME attribute not found for %I64x\n", Id);
+            Status = STATUS_OBJECT_PATH_NOT_FOUND;
+            break;
+        }
+
         WritePosition -= FileName->NameLength;
         ASSERT(WritePosition < MAX_PATH);
         RtlCopyMemory(FullPath + WritePosition, FileName->Name, FileName->NameLength * sizeof(WCHAR));
         WritePosition -= FileName->NameLength;
         ASSERT(WritePosition < MAX_PATH);
         RtlCopyMemory(FullPath + WritePosition, FileName->Name, FileName->NameLength * sizeof(WCHAR));
@@ -276,10 +281,19 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
 
     if ((RequestedOptions & FILE_OPEN_BY_FILE_ID) == FILE_OPEN_BY_FILE_ID)
     {
 
     if ((RequestedOptions & FILE_OPEN_BY_FILE_ID) == FILE_OPEN_BY_FILE_ID)
     {
+        ULONGLONG MFTId;
+
         if (FileObject->FileName.Length != sizeof(ULONGLONG))
             return STATUS_INVALID_PARAMETER;
 
         if (FileObject->FileName.Length != sizeof(ULONGLONG))
             return STATUS_INVALID_PARAMETER;
 
-        Status = NtfsMoonWalkID(DeviceExt, (*(PULONGLONG)FileObject->FileName.Buffer), &FullPath);
+        MFTId = (*(PULONGLONG)FileObject->FileName.Buffer) & NTFS_MFT_MASK;
+        if (MFTId < 0xf)
+        {
+            UNIMPLEMENTED;
+            return STATUS_NOT_IMPLEMENTED;
+        }
+
+        Status = NtfsMoonWalkID(DeviceExt, MFTId, &FullPath);
         if (!NT_SUCCESS(Status))
         {
             return Status;
         if (!NT_SUCCESS(Status))
         {
             return Status;