Browse Source

SMB1: Improved handling of UnsupportedInformationLevelException

Tal Aloni 8 years ago
parent
commit
112ab74cc3

+ 10 - 1
SMBLibrary/Server/SMB1/Transaction2SubcommandHelper.cs

@@ -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);

+ 2 - 18
SMBLibrary/Server/SMBServer.SMB1.cs

@@ -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)
                     {