#751: add some tracer bullets to help track down this error.

This commit is contained in:
Charles Kerr 2008-03-03 21:51:45 +00:00
parent 20fd7f3456
commit 3000d67e7f
1 changed files with 21 additions and 8 deletions

View File

@ -681,17 +681,30 @@ reqIsValid( const tr_peermsgs * msgs,
uint32_t length )
{
const tr_torrent * tor = msgs->torrent;
int err = 0;
if( index >= (uint32_t) tor->info.pieceCount )
return FALSE;
if ( (int)offset >= tr_torPieceCountBytes( tor, (int)index ) )
return FALSE;
if( length > MAX_REQUEST_BYTE_COUNT )
return FALSE;
if( tr_pieceOffset( tor, index, offset, length ) > tor->info.totalSize )
return FALSE;
err = 1;
else if ( (int)offset >= tr_torPieceCountBytes( tor, (int)index ) )
err = 2;
else if( length > MAX_REQUEST_BYTE_COUNT )
err = 3;
else if( tr_pieceOffset( tor, index, offset, length ) > tor->info.totalSize )
err = 4;
return TRUE;
if( !err )
{
fprintf( stderr, "(ticket #751) err is %d\n", err );
fprintf( stderr, "(ticket #751) req.index is %"PRIu32"\n", index );
fprintf( stderr, "(ticket #751) req.offset is %"PRIu32"\n", offset );
fprintf( stderr, "(ticket #751) req.length is %"PRIu32"\n", length );
fprintf( stderr, "(ticket #751) tor->info.totalSize is %"PRIu64"\n", tor->info.totalSize );
fprintf( stderr, "(ticket #751) tor->info.pieceCount is %d\n", tor->info.pieceCount );
fprintf( stderr, "(ticket #751) tr_torPieceCountBytes is %d\n", tr_torPieceCountBytes( tor, (int)index ) );
fprintf( stderr, "(ticket #751) tr_pieceOffset is %"PRIu64"\n", tr_pieceOffset( tor, index, offset, length ) );
}
return !err;
}
static int