(trunk, libT) #5049: fix bug that caused some incoming encrypted peer connections to fail

This commit is contained in:
Jordan Lee 2012-09-25 02:07:03 +00:00
parent cf9d109480
commit b437b28228
1 changed files with 6 additions and 1 deletions

View File

@ -868,14 +868,19 @@ static int
readPadC( tr_handshake * handshake,
struct evbuffer * inbuf )
{
char * padc;
uint16_t ia_len;
const size_t needlen = handshake->pad_c_len + sizeof( uint16_t );
if( evbuffer_get_length( inbuf ) < needlen )
return READ_LATER;
evbuffer_drain( inbuf, handshake->pad_c_len );
/* read the throwaway padc */
padc = tr_new (char, handshake->pad_c_len);
tr_peerIoReadBytes (handshake->io, inbuf, padc, handshake->pad_c_len);
tr_free (padc);
/* read ia_len */
tr_peerIoReadUint16( handshake->io, inbuf, &ia_len );
dbgmsg( handshake, "ia_len is %d", (int)ia_len );
handshake->ia_len = ia_len;