Be more flexible in case the dictionary isn't at the beginning of the

body (refs http://transmission.m0k.org/forum/viewtopic.php?t=298)
This commit is contained in:
Eric Petit 2006-05-03 17:41:51 +00:00
parent 49fccfd96e
commit 9235d148b0
1 changed files with 3 additions and 11 deletions

View File

@ -440,12 +440,11 @@ static void recvAnswer( tr_tracker_t * tc )
}
bodylen = tc->pos - (body - tc->buf);
/* Find the beginning of the dictionary */
/* Find and load the dictionary */
for( i = 0; i < bodylen; i++ )
{
if( body[i] == 'd' )
if( !tr_bencLoad( &body[i], bodylen - i, &beAll, NULL ) )
{
/* This must be it */
break;
}
}
@ -457,14 +456,7 @@ static void recvAnswer( tr_tracker_t * tc )
tc->lastAttempt = TC_ATTEMPT_OK;
goto nodict;
}
tr_err( "Tracker: no dictionary in answer" );
tc->lastAttempt = TC_ATTEMPT_ERROR;
return;
}
if( tr_bencLoad( &body[i], bodylen - i, &beAll, NULL ) )
{
tr_err( "Tracker: error parsing bencoded data" );
tr_err( "Tracker: no valid dictionary found in answer" );
tc->lastAttempt = TC_ATTEMPT_ERROR;
return;
}