Browse Source

SMBServer: Correct handling of STATUS_BUFFER_OVERFLOW returned by the NTFileStore

Tal Aloni 7 years atrás
parent
commit
4fef34e7cd

+ 2 - 2
SMBLibrary/Server/SMB1/NTTransactHelper.cs

@@ -103,7 +103,7 @@ namespace SMBLibrary.Server.SMB1
                 header.Status = NTStatus.STATUS_SMB_BAD_COMMAND;
             }
 
-            if (header.Status != NTStatus.STATUS_SUCCESS)
+            if (subcommandResponse == null)
             {
                 return new ErrorResponse(CommandName.SMB_COM_NT_TRANSACT);
             }
@@ -129,7 +129,7 @@ namespace SMBLibrary.Server.SMB1
                 int maxOutputLength = (int)maxDataCount;
                 byte[] output;
                 header.Status = share.FileStore.DeviceIOControl(openFile.Handle, subcommand.FunctionCode, subcommand.Data, out output, maxOutputLength);
-                if (header.Status != NTStatus.STATUS_SUCCESS)
+                if (header.Status != NTStatus.STATUS_SUCCESS && header.Status != NTStatus.STATUS_BUFFER_OVERFLOW)
                 {
                     return null;
                 }

+ 1 - 1
SMBLibrary/Server/SMB1/TransactionHelper.cs

@@ -167,7 +167,7 @@ namespace SMBLibrary.Server.SMB1
                 header.Status = NTStatus.STATUS_SMB_BAD_COMMAND;
             }
 
-            if (header.Status != NTStatus.STATUS_SUCCESS)
+            if (subcommandResponse == null)
             {
                 return new ErrorResponse(CommandName.SMB_COM_TRANSACTION);
             }

+ 1 - 1
SMBLibrary/Server/SMB1/TransactionSubcommandHelper.cs

@@ -29,7 +29,7 @@ namespace SMBLibrary.Server.SMB1
             int maxOutputLength = (int)maxDataCount;
             byte[] output;
             header.Status = share.FileStore.DeviceIOControl(openFile.Handle, (uint)IoControlCode.FSCTL_PIPE_TRANSCEIVE, subcommand.WriteData, out output, maxOutputLength);
-            if (header.Status != NTStatus.STATUS_SUCCESS)
+            if (header.Status != NTStatus.STATUS_SUCCESS && header.Status != NTStatus.STATUS_BUFFER_OVERFLOW)
             {
                 return null;
             }

+ 2 - 1
SMBLibrary/Server/SMB2/IOCtlHelper.cs

@@ -49,12 +49,13 @@ namespace SMBLibrary.Server.SMB2
             int maxOutputLength = (int)request.MaxOutputResponse;
             byte[] output;
             NTStatus status = share.FileStore.DeviceIOControl(handle, request.CtlCode, request.Input, out output, maxOutputLength);
-            if (status != NTStatus.STATUS_SUCCESS)
+            if (status != NTStatus.STATUS_SUCCESS && status != NTStatus.STATUS_BUFFER_OVERFLOW)
             {
                 return new ErrorResponse(request.CommandName, status);
             }
 
             IOCtlResponse response = new IOCtlResponse();
+            response.Header.Status = status;
             response.CtlCode = request.CtlCode;
             response.FileId = request.FileId;
             response.Output = output;