[KMTESTS:IO]
authorThomas Faber <thomas.faber@reactos.org>
Sun, 26 Feb 2017 11:31:51 +0000 (11:31 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 26 Feb 2017 11:31:51 +0000 (11:31 +0000)
- Avoid a crash in IoFilesystem on Windows when using a free kernel with ntfs. Querying FileAllInformation with any size below sizeof(FILE_ALL_INFORMATION) is considered illegal, so only do it on checked builds (which have a size check).

svn path=/trunk/; revision=73921

rostests/kmtests/ntos_io/IoFilesystem.c

index 6c12521..65c7635 100644 (file)
@@ -113,15 +113,26 @@ TestAllInformation(VOID)
     Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
     ok_eq_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
     ok_eq_size(Length, (ULONG_PTR)0x5555555555555555);
     Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
     ok_eq_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
     ok_eq_size(Length, (ULONG_PTR)0x5555555555555555);
+    if (FileAllInfo)
+        KmtFreeGuarded(FileAllInfo);
+
+    /* No space for the name -- fastfat handles this gracefully, ntfs doesn't.
+     * But the Io manager makes it fail on checked builds, so it's
+     * technically illegal
+     */
+    Length = FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName);
+    Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
+    ok_eq_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
+    ok_eq_size(Length, (ULONG_PTR)0x5555555555555555);
     if (FileAllInfo)
         KmtFreeGuarded(FileAllInfo);
     }
 
     /* The minimum allowed */
     if (FileAllInfo)
         KmtFreeGuarded(FileAllInfo);
     }
 
     /* The minimum allowed */
-    Length = FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName);
+    Length = sizeof(FILE_ALL_INFORMATION);
     Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
     ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
     Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
     ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
-    ok_eq_size(Length, FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName));
+    ok_eq_size(Length, sizeof(FILE_ALL_INFORMATION));
     if (FileAllInfo)
         KmtFreeGuarded(FileAllInfo);
 
     if (FileAllInfo)
         KmtFreeGuarded(FileAllInfo);