Forráskód Böngészése

Added SMB1Header.IsValidSMB1Header method

Tal Aloni 8 éve
szülő
commit
eee2078581
2 módosított fájl, 13 hozzáadás és 13 törlés
  1. 11 1
      SMBLibrary/SMB1/SMB1Header.cs
  2. 2 12
      SMBLibrary/SMB1/SMB1Message.cs

+ 11 - 1
SMBLibrary/SMB1/SMB1Header.cs

@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
+/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  * 
  * You can redistribute this program and/or modify it under the terms of
  * the GNU Lesser Public License as published by the Free Software Foundation,
@@ -115,5 +115,15 @@ namespace SMBLibrary.SMB1
                 return (Flags2 & HeaderFlags2.Unicode) > 0;
             }
         }
+
+        public static bool IsValidSMB1Header(byte[] buffer)
+        {
+            if (buffer.Length >= 4)
+            {
+                byte[] signature = ByteReader.ReadBytes(buffer, 0, 4);
+                return ByteUtils.AreByteArraysEqual(signature, ProtocolSignature);
+            }
+            return false;
+        }
     }
 }

+ 2 - 12
SMBLibrary/SMB1/SMB1Message.cs

@@ -95,21 +95,11 @@ namespace SMBLibrary.SMB1
             return buffer;
         }
 
-        public static bool IsValidSMB1Message(byte[] buffer)
-        {
-            if (buffer.Length >= 4)
-            {
-                byte[] signature = ByteReader.ReadBytes(buffer, 0, 4);
-                return ByteUtils.AreByteArraysEqual(signature, SMB1Header.ProtocolSignature);
-            }
-            return false;
-        }
-
         public static SMB1Message GetSMB1Message(byte[] buffer)
         {
-            if (!IsValidSMB1Message(buffer))
+            if (!SMB1Header.IsValidSMB1Header(buffer))
             {
-                throw new InvalidRequestException("Invalid SMB message signature");;
+                throw new InvalidRequestException("Invalid SMB header signature");;
             }
             return new SMB1Message(buffer);
         }