From 056558576ef37d1b135a948962eb30f428396247 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 27 Aug 2006 18:38:30 +0000 Subject: [PATCH] fixed overflow bug in file_progress() and bug in the parsing of dht nodes from torrent files --- include/libtorrent/peer_request.hpp | 2 +- src/torrent.cpp | 11 ++++++----- src/torrent_info.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/libtorrent/peer_request.hpp b/include/libtorrent/peer_request.hpp index ff4033ad3..445ff4d7e 100644 --- a/include/libtorrent/peer_request.hpp +++ b/include/libtorrent/peer_request.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2003, Arvid Norberg +Copyright (c) 2006, Arvid Norberg All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/torrent.cpp b/src/torrent.cpp index 80d7741e3..3dfda8218 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1724,18 +1724,19 @@ namespace libtorrent for (int i = 0; i < m_torrent_file.num_files(); ++i) { - peer_request ret = m_torrent_file.map_file(i, 0, m_torrent_file.file_at(i).size); + peer_request ret = m_torrent_file.map_file(i, 0, 0); + size_type size = m_torrent_file.file_at(i).size; size_type done = 0; - while (ret.length > 0) + while (size > 0) { size_type bytes_step = std::min(m_torrent_file.piece_size(ret.piece) - - ret.start, (size_type)ret.length); + - ret.start, size); if (m_have_pieces[ret.piece]) done += bytes_step; ++ret.piece; ret.start = 0; - ret.length -= bytes_step; + size -= bytes_step; } - assert(ret.length == 0); + assert(size == 0); fp[i] = static_cast(done) / m_torrent_file.file_at(i).size; } diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index ab0e96b71..c384070ed 100755 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -345,7 +345,7 @@ namespace libtorrent std::string const& hostname = iter->string(); ++iter; int port = 6881; - if (list.end() != iter) port = iter->integer(); + if (l.end() != iter) port = iter->integer(); m_nodes.push_back(std::make_pair(hostname, port)); } }