diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 60f1d939..9f37b11a 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,7 @@ namespace torrents { size_t len = 0; auto res = std::from_chars(buf.data(), buf.data() + pos, len); - if (res.ec == std::errc()) + if (res.ec == std::errc() && len <= std::numeric_limits::max () - pos - 1) { size_t totalLength = len + pos + 1; if (totalLength <= buf.length ())