mirror of
https://github.com/transmission/transmission
synced 2024-12-23 08:13:27 +00:00
#5912: Prevent completed pieces modification by webseeds (patch by cfpp2p)
This avoids blocks corruption in case webseed provides bad data. As explained by cfpp2p, "The requirements to reproduce are at least one webseed that sends corrupt block(s), and at least one other peer (webseed or regular peer) that sends correct data for the same block. Then a peer with correct block sends the block and transmission accepts and verifies that block as good. But then the webseed thread comes around and the same block is downloaded from the webseed that sends a bad block which is then written even though the piece was previously deemed complete."
This commit is contained in:
parent
6cbfcdc85e
commit
b9adf279ca
1 changed files with 10 additions and 7 deletions
|
@ -162,6 +162,8 @@ write_block_func (void * vdata)
|
|||
tr_cache * cache = data->session->cache;
|
||||
const tr_piece_index_t piece = data->piece_index;
|
||||
|
||||
if (!tr_torrentPieceIsComplete (tor, piece))
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
const uint32_t bytes_this_pass = MIN (len, block_size);
|
||||
|
@ -171,6 +173,7 @@ write_block_func (void * vdata)
|
|||
|
||||
fire_client_got_blocks (tor, w, data->block_index, data->count);
|
||||
}
|
||||
}
|
||||
|
||||
evbuffer_free (buf);
|
||||
tr_free (data);
|
||||
|
@ -422,7 +425,7 @@ web_response_func (tr_session * session,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (buf_len)
|
||||
if (buf_len && !tr_torrentPieceIsComplete (tor, t->piece_index))
|
||||
{
|
||||
/* on_content_changed () will not write a block if it is smaller than
|
||||
the torrent's block size, i.e. the torrent's very last block */
|
||||
|
|
Loading…
Reference in a new issue