1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-15 10:54:42 +00:00

fix: integer overflow when calculating sizeWhenDone (#2378)

While the function correctly returns a `uint64_t`, internally a `size_t` variable is used to calculate the accumulated size.
On 32-bit systems (e.g. Raspbian) `size_t` is only 32-bit wide, causing overflow for torrents > 4GB.
This commit is contained in:
Frank Aurich 2022-01-07 17:48:08 +01:00 committed by GitHub
parent a5c6168805
commit 319312596a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,7 +56,7 @@ uint64_t tr_completion::computeSizeWhenDone() const
}
// count bytes that we want or that we already have
auto size = size_t{ 0 };
auto size = uint64_t{ 0 };
for (tr_piece_index_t piece = 0; piece < block_info_->n_pieces; ++piece)
{
if (tor_->pieceIsWanted(piece))