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

This commit is contained in:
Tal Aloni 2017-05-23 10:57:42 +03:00
parent 29a18fbfea
commit 4f28519223

View file

@ -78,10 +78,12 @@ namespace SMBLibrary.Server.SMB2
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);
pageLength += fileInformation.Length;
int paddedLength = (int)Math.Ceiling((double)entryLength / 8) * 8;
pageLength += paddedLength;
openSearch.EnumerationLocation = index + 1;
}
else