From fc959a0ad672d72e177c8f9a2a0fb66322ccd8a0 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 24 Jun 2011 21:44:29 +0000 Subject: [PATCH] fixed a bug in pqissl and pqistreamer. The 2nd one was responsible for disconnections and errors in GetTlvString type git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4332 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/pqissl.cc | 18 +++++++++--------- libretroshare/src/pqi/pqistreamer.cc | 11 +++++++++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/libretroshare/src/pqi/pqissl.cc b/libretroshare/src/pqi/pqissl.cc index b02b21d80..10c942f6c 100644 --- a/libretroshare/src/pqi/pqissl.cc +++ b/libretroshare/src/pqi/pqissl.cc @@ -1478,18 +1478,18 @@ int pqissl::readdata(void *data, int len) #ifdef DEBUG_PQISSL std::cerr << "calling SSL_read. len=" << len << ", total_len=" << total_len << std::endl ; #endif - tmppktlen = SSL_read(ssl_connection, (void*)((unsigned long int)data+(unsigned long int)total_len), len-total_len) ; + tmppktlen = SSL_read(ssl_connection, (void*)( &(((uint8_t*)data)[total_len])), len-total_len) ; #ifdef DEBUG_PQISSL std::cerr << "have read " << tmppktlen << " bytes" << std::endl ; std::cerr << "data[0] = " - << (int)((uint8_t*)data)[0] << " " - << (int)((uint8_t*)data)[1] << " " - << (int)((uint8_t*)data)[2] << " " - << (int)((uint8_t*)data)[3] << " " - << (int)((uint8_t*)data)[4] << " " - << (int)((uint8_t*)data)[5] << " " - << (int)((uint8_t*)data)[6] << " " - << (int)((uint8_t*)data)[7] << std::endl ; + << (int)((uint8_t*)data)[total_len+0] << " " + << (int)((uint8_t*)data)[total_len+1] << " " + << (int)((uint8_t*)data)[total_len+2] << " " + << (int)((uint8_t*)data)[total_len+3] << " " + << (int)((uint8_t*)data)[total_len+4] << " " + << (int)((uint8_t*)data)[total_len+5] << " " + << (int)((uint8_t*)data)[total_len+6] << " " + << (int)((uint8_t*)data)[total_len+7] << std::endl ; #endif // Need to catch errors..... diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index bdc287c26..12120914f 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -44,6 +44,7 @@ const int PQISTREAM_ABS_MAX = 100000000; /* 100 MB/sec (actually per loop) */ /*** #define RSITEM_DEBUG 1 #define DEBUG_TRANSFERS 1 +#define DEBUG_PQISTREAMER 1 ***/ @@ -707,8 +708,14 @@ continue_packet: { void *extradata = (void *) (((char *) block) + blen); int tmplen ; - // reset the block, to avoid uninitialized memory reads. - memset( extradata,0,extralen ) ; // for checking later + + // Don't reset the block now! If pqissl is in the middle of a multiple-chunk + // packet (larger than 16384 bytes), and pqistreamer jumped directly yo + // continue_packet:, then readdata is going to write after the beginning of + // extradata, yet not exactly at start -> the start of the packet would be wiped out. + // + // so, don't do that: + // memset( extradata,0,extralen ) ; if (extralen != (tmplen = bio->readdata(extradata, extralen))) {