1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

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

View file

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