From b51b6b14ae003361061d13318fc42c10b7e2aa3d Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 14 Oct 2010 17:12:12 +0000 Subject: [PATCH] (trunk libT) #3631 "crash in tr_ioFindFileLocation" -- more tracer messages for the testers @ https://forum.transmissionbt.com/viewtopic.php?p=49625#p49625 --- libtransmission/inout.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libtransmission/inout.c b/libtransmission/inout.c index 54e2ff857..02828e63c 100644 --- a/libtransmission/inout.c +++ b/libtransmission/inout.c @@ -188,23 +188,26 @@ tr_ioFindFileLocation( const tr_torrent * tor, const tr_file * file; assert( tr_isTorrent( tor ) ); + +if( offset >= tor->info.totalSize ) +{ +tr_file_index_t i; +fprintf( stderr, "looking for torrent offset is %"PRIu64"\n", offset ); +fprintf( stderr, "total torrent size %"PRIu64"\n", tor->info.totalSize ); +fprintf( stderr, "pieceIndex %d\n", (int)pieceIndex ); +fprintf( stderr, "pieceOffset %d\n", (int)pieceOffset ); +fprintf( stderr, "piece size is %d\n", (int)tor->info.pieceSize ); +fprintf( stderr, "last piece size is %d\n", (int)tor->lastPieceSize ); +fprintf( stderr, "%u files\n", (unsigned int)tor->info.fileCount ); +for( i=0; iinfo.fileCount; ++i ) fprintf( stderr, "file #%u offset %"PRIu64" length %"PRIu64"\n", i, tor->info.files[i].offset, tor->info.files[i].length ); +} + assert( offset < tor->info.totalSize ); file = bsearch( &offset, tor->info.files, tor->info.fileCount, sizeof( tr_file ), compareOffsetToFile ); -if( file == NULL ) { -unsigned int i; -fprintf( stderr, "%s", "transmission error\n" ); -fprintf( stderr, "pieceIndex %d\n", (int)pieceIndex ); -fprintf( stderr, "pieceOffset %d\n", (int)pieceOffset ); -fprintf( stderr, "couldn't find file matching offset %"PRIu64"\n", offset ); -fprintf( stderr, "total torrent size %"PRIu64"\n", tor->info.totalSize ); -fprintf( stderr, "%u files\n", (unsigned int)tor->info.fileCount ); -for( i=0; iinfo.fileCount; ++i ) fprintf( stderr, "file #%u offset %"PRIu64" length %"PRIu64"\n", i, tor->info.files[i].offset, tor->info.files[i].length ); -} - assert( file != NULL ); *fileIndex = file - tor->info.files;