From 2ea5115bccc5940d7e3082279ae06e3bdcc36423 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 1 Oct 2017 19:47:01 +0200 Subject: [PATCH] fix the torrent_info size overflow check --- src/torrent_info.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index ee55fd179..b6a7710ff 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -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::max() / files.piece_length()) - - files.piece_length()) + if (files.total_size() >= static_cast(std::numeric_limits::max() - files.piece_length()) + * files.piece_length()) { ec = errors::too_many_pieces_in_torrent; // mark the torrent as invalid