From 83f626c18ee43e4f00871a8007b930a4be3b0cd4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 5 Mar 2013 00:32:57 +0000 Subject: [PATCH] fixed test_torrent_parse test --- src/torrent_info.cpp | 7 +++---- test/test_torrent_parse.cpp | 2 +- test/test_torrents/invalid_root_hash2.torrent | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 test/test_torrents/invalid_root_hash2.torrent diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index e28cd118d..9f903df95 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -964,10 +964,9 @@ namespace libtorrent m_files.set_num_pieces(int((m_files.total_size() + m_files.piece_length() - 1) / m_files.piece_length())); - lazy_entry const* pieces = info.dict_find("pieces"); - lazy_entry const* root_hash = info.dict_find("root hash"); - if ((pieces == 0 || pieces->type() != lazy_entry::string_t) - && (root_hash == 0 || root_hash->type() != lazy_entry::string_t)) + lazy_entry const* pieces = info.dict_find_string("pieces"); + lazy_entry const* root_hash = info.dict_find_string("root hash"); + if (pieces == 0 && root_hash == 0) { ec = errors::torrent_missing_pieces; return false; diff --git a/test/test_torrent_parse.cpp b/test/test_torrent_parse.cpp index 13a40a59e..3e1f9f864 100644 --- a/test/test_torrent_parse.cpp +++ b/test/test_torrent_parse.cpp @@ -95,7 +95,7 @@ test_failing_torrent_t test_error_torrents[] = { "invalid_pieces.torrent", errors::torrent_missing_pieces }, { "unaligned_pieces.torrent", errors::torrent_invalid_hashes }, { "invalid_root_hash.torrent", errors::torrent_invalid_hashes }, - { "invalid_root_hash2.torrent", errors::torrent_invalid_hashes }, + { "invalid_root_hash2.torrent", errors::torrent_missing_pieces}, { "invalid_file_size.torrent", errors::torrent_file_parse_failed }, }; diff --git a/test/test_torrents/invalid_root_hash2.torrent b/test/test_torrents/invalid_root_hash2.torrent new file mode 100644 index 000000000..927fb07cd --- /dev/null +++ b/test/test_torrents/invalid_root_hash2.torrent @@ -0,0 +1 @@ +d10:created by10:libtorrent13:creation datei1359599503e4:infod6:lengthi425e4:name4:temp12:piece lengthi16384e9:root hashi1343eee