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
This commit is contained in:
csoler 2011-06-24 21:44:29 +00:00
parent cc8021b0a6
commit fc959a0ad6
2 changed files with 18 additions and 11 deletions

View File

@ -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.....

View File

@ -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)))
{