فهرست منبع

2008-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Fixed the previous insufficient fix for possible busy loop.
	* src/MSEHandshake.cc (identifyHandshakeType)

	Removed unused functions.
	* src/MSEHandshake.{h, cc} (readDataAndDecrypt)
Tatsuhiro Tsujikawa 17 سال پیش
والد
کامیت
c766d945ef
3فایلهای تغییر یافته به همراه14 افزوده شده و 15 حذف شده
  1. 8 0
      ChangeLog
  2. 6 13
      src/MSEHandshake.cc
  3. 0 2
      src/MSEHandshake.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-02-28  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Fixed the previous insufficient fix for possible busy loop.
+	* src/MSEHandshake.cc (identifyHandshakeType)
+
+	Removed unused functions.
+	* src/MSEHandshake.{h, cc} (readDataAndDecrypt)
+
 2008-02-28  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Fixed possible busy loop if first 20 bytes are not received for a few

+ 6 - 13
src/MSEHandshake.cc

@@ -91,9 +91,12 @@ MSEHandshake::HANDSHAKE_TYPE MSEHandshake::identifyHandshakeType()
   if(!_socket->isReadable(0)) {
     return HANDSHAKE_NOT_YET;
   }
-  int32_t bufLength = 20-_rbufLength;
-  _socket->readData(_rbuf+_rbufLength, bufLength);
-  _rbufLength += bufLength;
+  int32_t r = 20-_rbufLength;
+  _socket->readData(_rbuf+_rbufLength, r);
+  if(r == 0) {
+    throw new DlAbortEx(EX_EOF_FROM_PEER);
+  }
+  _rbufLength += r;
   if(_rbufLength < 20) {
     return HANDSHAKE_NOT_YET;
   }
@@ -180,16 +183,6 @@ void MSEHandshake::initCipher(const unsigned char* infoHash)
   }
 }
 
-ssize_t MSEHandshake::readDataAndDecrypt(unsigned char* data, size_t length)
-{
-  unsigned char temp[MAX_BUFFER_LENGTH];
-  assert(MAX_BUFFER_LENGTH >= length);
-  int32_t rlength = length;
-  _socket->readData(temp, rlength);
-  _decryptor->decrypt(data, rlength, temp, rlength);
-  return rlength;
-}
-
 void MSEHandshake::encryptAndSendData(const unsigned char* data, size_t length)
 {
   unsigned char temp[4096];

+ 0 - 2
src/MSEHandshake.h

@@ -102,8 +102,6 @@ private:
 
   static const unsigned char VC[VC_LENGTH];
 
-  ssize_t readDataAndDecrypt(unsigned char* data, size_t length);
-
   void encryptAndSendData(const unsigned char* data, size_t length);
 
   void createReq1Hash(unsigned char* md) const;