fixed overflow bug in file_progress() and bug in the parsing of dht nodes from torrent files

This commit is contained in:
Arvid Norberg 2006-08-27 18:38:30 +00:00
parent 99391c9b90
commit 056558576e
3 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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<float>(done) / m_torrent_file.file_at(i).size;
}

View File

@ -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));
}
}