fix the torrent_info size overflow check

This commit is contained in:
arvidn 2017-10-01 19:47:01 +02:00 committed by Arvid Norberg
parent 21fef88928
commit 2ea5115bcc
1 changed files with 2 additions and 3 deletions

View File

@ -1016,9 +1016,8 @@ namespace {
// we want this division to round upwards, that's why we have the
// extra addition
if (files.total_size() >=
(std::numeric_limits<std::int64_t>::max() / files.piece_length())
- files.piece_length())
if (files.total_size() >= static_cast<std::int64_t>(std::numeric_limits<int>::max() - files.piece_length())
* files.piece_length())
{
ec = errors::too_many_pieces_in_torrent;
// mark the torrent as invalid