summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2009-01-04 08:48:46 +0000
committerAndrew Resch <andrewresch@gmail.com>2009-01-04 08:48:46 +0000
commit7226cbb53d13aad04621790d6c2a741f2abda8bb (patch)
tree8d2e48e23131bd5bdb01dbadcbfba143486f80da
parentf168f7e18e35e3ca078328986be301262654a5f2 (diff)
downloaddeluge-7226cbb53d13aad04621790d6c2a741f2abda8bb.tar.gz
deluge-7226cbb53d13aad04621790d6c2a741f2abda8bb.tar.bz2
deluge-7226cbb53d13aad04621790d6c2a741f2abda8bb.zip
lt sync 3129
-rw-r--r--libtorrent/src/disk_io_thread.cpp2
-rw-r--r--libtorrent/src/kademlia/dht_tracker.cpp2
-rw-r--r--libtorrent/src/kademlia/rpc_manager.cpp2
-rwxr-xr-xlibtorrent/src/torrent.cpp2
-rwxr-xr-xlibtorrent/src/torrent_info.cpp21
5 files changed, 21 insertions, 8 deletions
diff --git a/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp
index 3ff193c3c..e446964b0 100644
--- a/libtorrent/src/disk_io_thread.cpp
+++ b/libtorrent/src/disk_io_thread.cpp
@@ -452,7 +452,7 @@ namespace libtorrent
{
l.unlock();
ret += p.storage->read_impl(p.blocks[i], p.piece, piece_offset, block_size);
- if (!p.storage->error()) { return -1; }
+ if (p.storage->error()) { return -1; }
l.lock();
++m_cache_stats.reads;
}
diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp
index 485471555..88bc7738d 100644
--- a/libtorrent/src/kademlia/dht_tracker.cpp
+++ b/libtorrent/src/kademlia/dht_tracker.cpp
@@ -298,7 +298,7 @@ namespace libtorrent { namespace dht
int peers = 0;
std::for_each(m_dht.begin_data(), m_dht.end_data(), count_peers(peers));
- std::ofstream pc("libtorrent_logs/dht_stats.log", std::ios_base::app);
+ std::ofstream pc("libtorrent_logs/dht_stats.log", first ? std::ios_base::trunc : std::ios_base::app);
if (first)
{
first = false;
diff --git a/libtorrent/src/kademlia/rpc_manager.cpp b/libtorrent/src/kademlia/rpc_manager.cpp
index 6aa410061..a2082b2e3 100644
--- a/libtorrent/src/kademlia/rpc_manager.cpp
+++ b/libtorrent/src/kademlia/rpc_manager.cpp
@@ -263,7 +263,7 @@ bool rpc_manager::incoming(msg const& m)
}
#ifdef TORRENT_DHT_VERBOSE_LOGGING
- std::ofstream reply_stats("libtorrent_logs/round_trip_ms.log", std::ios::app);
+ std::ofstream reply_stats("round_trip_ms.log", std::ios::app);
reply_stats << m.addr << "\t" << total_milliseconds(time_now() - o->sent)
<< std::endl;
#endif
diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp
index dffcf18bc..efb97a77d 100755
--- a/libtorrent/src/torrent.cpp
+++ b/libtorrent/src/torrent.cpp
@@ -3421,6 +3421,8 @@ namespace libtorrent
TORRENT_ASSERT(m_torrent_file->is_valid());
INVARIANT_CHECK;
+ if (m_abort) return;
+
// we might be finished already, in which case we should
// not switch to downloading mode.
if (m_state != torrent_status::finished)
diff --git a/libtorrent/src/torrent_info.cpp b/libtorrent/src/torrent_info.cpp
index e7f173d6c..7c109e693 100755
--- a/libtorrent/src/torrent_info.cpp
+++ b/libtorrent/src/torrent_info.cpp
@@ -74,13 +74,12 @@ namespace
str += 0x80 | (chr & 0x3f);
}
- void verify_encoding(file_entry& target)
+ bool verify_encoding(std::string& target)
{
std::string tmp_path;
- std::string file_path = target.path.string();
bool valid_encoding = true;
- for (std::string::iterator i = file_path.begin()
- , end(file_path.end()); i != end; ++i)
+ for (std::string::iterator i = target.begin()
+ , end(target.end()); i != end; ++i)
{
// valid ascii-character
if ((*i & 0x80) == 0)
@@ -153,7 +152,14 @@ namespace
// save the original encoding and replace the
// commonly used path with the correctly
// encoded string
- if (!valid_encoding) target.path = tmp_path;
+ if (!valid_encoding) target = tmp_path;
+ return valid_encoding;
+ }
+
+ void verify_encoding(file_entry& target)
+ {
+ std::string p = target.path.string();
+ if (!verify_encoding(p)) target.path = p;
}
bool extract_single_file(lazy_entry const& dict, file_entry& target
@@ -420,6 +426,9 @@ namespace libtorrent
error = "invalid 'name' of torrent (possible exploit attempt)";
return false;
}
+
+ // correct utf-8 encoding errors
+ verify_encoding(name);
// extract file list
lazy_entry const* i = info.dict_find_list("files");
@@ -573,9 +582,11 @@ namespace libtorrent
m_comment = torrent_file.dict_find_string_value("comment.utf-8");
if (m_comment.empty()) m_comment = torrent_file.dict_find_string_value("comment");
+ verify_encoding(m_comment);
m_created_by = torrent_file.dict_find_string_value("created by.utf-8");
if (m_created_by.empty()) m_created_by = torrent_file.dict_find_string_value("created by");
+ verify_encoding(m_created_by);
lazy_entry const* info = torrent_file.dict_find_dict("info");
if (info == 0)