From 0e0733df97746990e656ea8e993d6bf771d2d3ab Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 17 Sep 2026 16:55:20 -0400 Subject: [PATCH] check piece's next hash string length --- libi2pd_client/Torrents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 57195997..9c4bd751 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -453,7 +453,7 @@ namespace torrents { auto [hashes, len] = ExtractByteString (buf); size_t totalLen = 0; - while (!hashes.empty () && totalLen < m_Length) + while (hashes.length () >= SHA_DIGEST_LENGTH && totalLen < m_Length) { auto l = (totalLen + m_PieceLength <= m_Length) ? m_PieceLength : m_Length - totalLen; m_Pieces.emplace_back (l, (const uint8_t *)hashes.substr (0, SHA_DIGEST_LENGTH).data ());