[FASTFAT] Properly check for buffer size on dir enumeration.
authorPierre Schweitzer <pierre@reactos.org>
Thu, 7 Jun 2018 17:33:23 +0000 (19:33 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 7 Jun 2018 17:34:47 +0000 (19:34 +0200)
This avoids improper returns when multiple entries are requested
and, in rare circumstances, entries not being seen by umode.

CORE-14699

drivers/filesystems/fastfat/dir.c

index 18c6dcc..b0b442a 100644 (file)
@@ -104,7 +104,7 @@ VfatGetFileNamesInformation(
     if (FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName) > BufferLength)
         return Status;
 
-    if (First || (BufferLength >= FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName) + DirContext->LongNameU.Length))
+    if (First || (BufferLength > FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName) + DirContext->LongNameU.Length))
     {
         pInfo->FileNameLength = DirContext->LongNameU.Length;
 
@@ -149,7 +149,7 @@ VfatGetFileDirectoryInformation(
     if (FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName) > BufferLength)
         return Status;
 
-    if (First || (BufferLength >= FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName) + DirContext->LongNameU.Length))
+    if (First || (BufferLength > FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName) + DirContext->LongNameU.Length))
     {
         pInfo->FileNameLength = DirContext->LongNameU.Length;
         /* pInfo->FileIndex = ; */
@@ -266,7 +266,7 @@ VfatGetFileFullDirectoryInformation(
     if (FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName) > BufferLength)
         return Status;
 
-    if (First || (BufferLength >= FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName) + DirContext->LongNameU.Length))
+    if (First || (BufferLength > FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName) + DirContext->LongNameU.Length))
     {
         pInfo->FileNameLength = DirContext->LongNameU.Length;
         /* pInfo->FileIndex = ; */
@@ -362,7 +362,7 @@ VfatGetFileBothInformation(
     if (FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName) > BufferLength)
         return Status;
 
-    if (First || (BufferLength >= FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName) + DirContext->LongNameU.Length))
+    if (First || (BufferLength > FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName) + DirContext->LongNameU.Length))
     {
         pInfo->FileNameLength = DirContext->LongNameU.Length;
         pInfo->EaSize = 0;