소스 검색

When receiving SSH_MSG_GLOBAL_REQUEST, only read data that is not message specific. Fixes issue #58.

drieseng 9 년 전
부모
커밋
7fce6e0b03
1개의 변경된 파일7개의 추가작업 그리고 31개의 파일을 삭제
  1. 7 31
      src/Renci.SshNet/Messages/Connection/GlobalRequestMessage.cs

+ 7 - 31
src/Renci.SshNet/Messages/Connection/GlobalRequestMessage.cs

@@ -1,4 +1,6 @@
-namespace Renci.SshNet.Messages.Connection
+using Renci.SshNet.Abstractions;
+
+namespace Renci.SshNet.Messages.Connection
 {
     /// <summary>
     /// Represents SSH_MSG_GLOBAL_REQUEST message.
@@ -7,7 +9,6 @@
     public class GlobalRequestMessage : Message
     {
         private byte[] _requestName;
-        private byte[] _addressToBind;
 
         /// <summary>
         /// Gets the name of the request.
@@ -15,9 +16,9 @@
         /// <value>
         /// The name of the request.
         /// </value>
-        public GlobalRequestName RequestName
+        public string RequestName
         {
-            get { return _requestName.ToGlobalRequestName(); }
+            get { return Ascii.GetString(_requestName); }
         }
 
         /// <summary>
@@ -28,20 +29,6 @@
         /// </value>
         public bool WantReply { get; private set; }
 
-        /// <summary>
-        /// Gets the address to bind to.
-        /// </summary>
-        public string AddressToBind
-        {
-            get { return Utf8.GetString(_addressToBind, 0, _addressToBind.Length); }
-            private set { _addressToBind = Utf8.GetBytes(value); }
-        }
-
-        /// <summary>
-        /// Gets port number to bind to.
-        /// </summary>
-        public uint PortToBind { get; private set; }
-
         /// <summary>
         /// Gets the size of the message in bytes.
         /// </summary>
@@ -56,9 +43,6 @@
                 capacity += 4; // RequestName length
                 capacity += _requestName.Length; // RequestName
                 capacity += 1; // WantReply
-                capacity += 4; // AddressToBind length
-                capacity += _addressToBind.Length; // AddressToBind
-                capacity += 4; // PortToBind
                 return capacity;
             }
         }
@@ -75,14 +59,10 @@
         /// </summary>
         /// <param name="requestName">Name of the request.</param>
         /// <param name="wantReply">if set to <c>true</c> [want reply].</param>
-        /// <param name="addressToBind">The address to bind.</param>
-        /// <param name="portToBind">The port to bind.</param>
-        public GlobalRequestMessage(GlobalRequestName requestName, bool wantReply, string addressToBind, uint portToBind)
+        internal GlobalRequestMessage(byte[] requestName, bool wantReply)
         {
-            _requestName = requestName.ToArray();
+            _requestName = requestName;
             WantReply = wantReply;
-            AddressToBind = addressToBind;
-            PortToBind = portToBind;
         }
 
         /// <summary>
@@ -92,8 +72,6 @@
         {
             _requestName = ReadBinary();
             WantReply = ReadBoolean();
-            _addressToBind = ReadBinary();
-            PortToBind = ReadUInt32();
         }
 
         /// <summary>
@@ -103,8 +81,6 @@
         {
             WriteBinaryString(_requestName);
             Write(WantReply);
-            WriteBinaryString(_addressToBind);
-            Write(PortToBind);
         }
     }
 }