From 1cfeb4debb79931314a7d9a34429f657d6c44707 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sat, 10 Dec 2011 18:42:52 +0000 Subject: [PATCH] (trunk libT) #4644 "Transmission can't download big files from webseed." -- fix overflow error with a patch based on one from and_cesbo. (Modified by Jordan to add random bugs.) --- libtransmission/webseed.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libtransmission/webseed.c b/libtransmission/webseed.c index 8cdcaa611..ddb4123b1 100644 --- a/libtransmission/webseed.c +++ b/libtransmission/webseed.c @@ -481,19 +481,20 @@ task_request_next_chunk( struct tr_webseed_task * t ) char ** urls = t->webseed->file_urls; const tr_info * inf = tr_torrentInfo( tor ); - const uint32_t remain = t->length - t->blocks_done * tor->blockSize + const uint64_t remain = t->length - t->blocks_done * tor->blockSize - evbuffer_get_length( t->content ); - const uint64_t total_offset = inf->pieceSize * t->piece_index - + t->piece_offset + t->length - remain; + const uint64_t total_offset = tr_pieceOffset( tor, t->piece_index, + t->piece_offset, + t->length - remain ); const tr_piece_index_t step_piece = total_offset / inf->pieceSize; - const uint32_t step_piece_offset + const uint64_t step_piece_offset = total_offset - ( inf->pieceSize * step_piece ); tr_file_index_t file_index; - uint64_t file_offset; const tr_file * file; - uint32_t this_pass; + uint64_t file_offset; + uint64_t this_pass; tr_ioFindFileLocation( tor, step_piece, step_piece_offset, &file_index, &file_offset );