Преглед на файлове

Bugfix: SMB2 QUERY_DIRECTORY response buffer length sometimes exceeded the request's OutputBufferLength

Tal Aloni преди 7 години
родител
ревизия
4f28519223
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      SMBLibrary/Server/SMB2/QueryDirectoryHelper.cs

+ 4 - 2
SMBLibrary/Server/SMB2/QueryDirectoryHelper.cs

@@ -78,10 +78,12 @@ namespace SMBLibrary.Server.SMB2
                     return new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_PARAMETER);
                     return new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_PARAMETER);
                 }
                 }
 
 
-                if (pageLength + fileInformation.Length <= request.OutputBufferLength)
+                int entryLength = fileInformation.Length;
+                if (pageLength + entryLength <= request.OutputBufferLength)
                 {
                 {
                     page.Add(fileInformation);
                     page.Add(fileInformation);
-                    pageLength += fileInformation.Length;
+                    int paddedLength = (int)Math.Ceiling((double)entryLength / 8) * 8;
+                    pageLength += paddedLength;
                     openSearch.EnumerationLocation = index + 1;
                     openSearch.EnumerationLocation = index + 1;
                 }
                 }
                 else
                 else