From be17c94088cdb410c77cb79eecd3ee1c6b2d1615 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 20 Sep 2026 12:51:31 -0400 Subject: [PATCH] check for possible buffer length value overflow --- libi2pd_client/Torrents.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ())