SMB1: Improved handling of UnsupportedInformationLevelException

This commit is contained in:
Tal Aloni 2017-03-15 11:52:58 +02:00
parent 198443b304
commit 112ab74cc3
2 changed files with 12 additions and 19 deletions

View file

@ -53,7 +53,16 @@ namespace SMBLibrary.Server.SMB1
int entriesToReturn = Math.Min(subcommand.SearchCount, entries.Count);
List<QueryDirectoryFileInformation> segment = entries.GetRange(0, entriesToReturn);
int maxLength = (int)state.GetMaxDataCount(header.PID).Value;
FindInformationList findInformationList = SMB1FileStoreHelper.GetFindInformationList(segment, subcommand.InformationLevel, header.UnicodeFlag, returnResumeKeys, maxLength);
FindInformationList findInformationList;
try
{
findInformationList = SMB1FileStoreHelper.GetFindInformationList(segment, subcommand.InformationLevel, header.UnicodeFlag, returnResumeKeys, maxLength);
}
catch (UnsupportedInformationLevelException)
{
header.Status = NTStatus.STATUS_OS2_INVALID_LEVEL;
return null;
}
int returnCount = findInformationList.Count;
Transaction2FindFirst2Response response = new Transaction2FindFirst2Response();
response.SetFindInformationList(findInformationList, header.UnicodeFlag);

View file

@ -257,28 +257,12 @@ namespace SMBLibrary.Server
else if (command is TransactionRequest) // Both TransactionRequest and Transaction2Request
{
TransactionRequest request = (TransactionRequest)command;
try
{
return TransactionHelper.GetTransactionResponse(header, request, share, state);
}
catch (UnsupportedInformationLevelException)
{
header.Status = NTStatus.STATUS_INVALID_PARAMETER;
return new ErrorResponse(command.CommandName);
}
return TransactionHelper.GetTransactionResponse(header, request, share, state);
}
else if (command is TransactionSecondaryRequest) // Both TransactionSecondaryRequest and Transaction2SecondaryRequest
{
TransactionSecondaryRequest request = (TransactionSecondaryRequest)command;
try
{
return TransactionHelper.GetTransactionResponse(header, request, share, state);
}
catch (UnsupportedInformationLevelException)
{
header.Status = NTStatus.STATUS_INVALID_PARAMETER;
return new ErrorResponse(command.CommandName);
}
return TransactionHelper.GetTransactionResponse(header, request, share, state);
}
else if (command is NTTransactRequest)
{