From d17866f6f9a750132b66def379de8628e7f352c9 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 1 Sep 2017 18:56:38 +0300 Subject: [PATCH] Minor code refactoring --- SMBLibrary/SMB1/Commands/NegotiateResponseExtended.cs | 3 +-- SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs | 4 ++-- SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs | 4 ++-- SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/SMBLibrary/SMB1/Commands/NegotiateResponseExtended.cs b/SMBLibrary/SMB1/Commands/NegotiateResponseExtended.cs index df2c8d8..84ecdd1 100644 --- a/SMBLibrary/SMB1/Commands/NegotiateResponseExtended.cs +++ b/SMBLibrary/SMB1/Commands/NegotiateResponseExtended.cs @@ -31,11 +31,10 @@ namespace SMBLibrary.SMB1 private byte ChallengeLength; // MUST be set to 0 // Data: public Guid ServerGuid; - public byte[] SecurityBlob; + public byte[] SecurityBlob; // [MS-SMB] 3.3.5.2: The server can leave SecurityBlob empty if not configured to send GSS token. public NegotiateResponseExtended() : base() { - // [MS-SMB] 3.3.5.2: The server can leave SecurityBlob empty if not configured to send GSS token. SecurityBlob = new byte[0]; } diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs index 973a691..c79e1aa 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs @@ -58,7 +58,7 @@ namespace SMBLibrary.SMB1 { // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // Note: SMBData starts at an odd offset. - int padding = (OEMPasswordLength + UnicodePasswordLength + 1) % 2; + int padding = (1 + OEMPasswordLength + UnicodePasswordLength) % 2; dataOffset += padding; } AccountName = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); @@ -86,7 +86,7 @@ namespace SMBLibrary.SMB1 { // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // Note: SMBData starts at an odd offset. - padding = (OEMPasswordLength + UnicodePasswordLength + 1) % 2; + padding = (1 + OEMPasswordLength + UnicodePasswordLength) % 2; this.SMBData = new byte[OEMPassword.Length + UnicodePassword.Length + padding + (AccountName.Length + 1) * 2 + (PrimaryDomain.Length + 1) * 2 + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2]; } else diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs index 159ba56..9c3f61f 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs @@ -51,7 +51,7 @@ namespace SMBLibrary.SMB1 { // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // Note: SMBData starts at an odd offset. - int padding = (SecurityBlobLength + 1) % 2; + int padding = (1 + SecurityBlobLength) % 2; dataOffset += padding; } NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); @@ -76,7 +76,7 @@ namespace SMBLibrary.SMB1 { // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // Note: SMBData starts at an odd offset. - padding = (SecurityBlobLength + 1) % 2; + padding = (1 + SecurityBlobLength) % 2; this.SMBData = new byte[SecurityBlob.Length + padding + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2]; } else diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs index c77e177..62bc2e8 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs @@ -45,7 +45,7 @@ namespace SMBLibrary.SMB1 { // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // Note: SMBData starts at an odd offset. - int padding = (SecurityBlobLength + 1) % 2; + int padding = (1 + SecurityBlobLength) % 2; dataOffset += padding; } NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);