[network/libktorrent] src/tracker: Fix num peers calculation for UDP Tracker

Jack Hill <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit e5636364de1642f222528c3e16b849b55843ce70 by Jack Hill.
Committed on 01/08/2026 at 12:22.
Pushed by jackh into branch 'master'.

Fix num peers calculation for UDP Tracker

The tracker will report the total number of seeders/leachers that is
knows of, but only send a subset of IPs.

BUG: 523426

M  +2    -2    src/tracker/udptracker.cpp

https://invent.kde.org/network/libktorrent/-/commit/e5636364de1642f222528c3e16b849b55843ce70

diff --git a/src/tracker/udptracker.cpp b/src/tracker/udptracker.cpp
index cd4a975f..c35e0445 100644
--- a/src/tracker/udptracker.cpp
+++ b/src/tracker/udptracker.cpp
@@ -135,9 +135,9 @@ void UDPTracker::announceReceived(Int32 tid, const bt::Uint8 *buf, bt::Uint32 si
     leechers = ReadInt32(buf, 12);
     seeders = ReadInt32(buf, 16);
 
-    const Uint32 nip = leechers + seeders;
     const auto ip_list = QByteArrayView{buf, size}.sliced(20);
-    for (Uint32 i = 0; i < nip; ++i) {
+    const auto num_peers = ip_list.size() / 6;
+    for (Uint32 i = 0; i < num_peers; ++i) {
         addPeer(net::Address::fromCompactIPv4(ip_list.sliced(i * 6, 6)), false);
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.