fix infinite loop when parsing certain invalid magnet links

This commit is contained in:
arvidn 2017-10-11 02:06:29 +02:00 committed by Arvid Norberg
parent a9524550d7
commit f19cca1374
3 changed files with 23 additions and 4 deletions

View File

@ -1,6 +1,7 @@
1.1.5 release 1.1.5 release
* fix infinite loop when parsing certain invalid magnet links
* fix parsing of torrents with certain invalid filenames * fix parsing of torrents with certain invalid filenames
* fix leak of torrent_peer objecs (entries in peer_list) * fix leak of torrent_peer objecs (entries in peer_list)
* fix leak of peer_class objects (when setting per-torrent rate limits) * fix leak of peer_class objects (when setting per-torrent rate limits)

View File

@ -194,8 +194,7 @@ namespace libtorrent
{ {
error_code e; error_code e;
url = unescape_string(url, e); url = unescape_string(url, e);
if (e) continue; if (!e) p.trackers.push_back(url);
p.trackers.push_back(url);
pos = uri.find("&tr=", pos); pos = uri.find("&tr=", pos);
if (pos == std::string::npos) break; if (pos == std::string::npos) break;
pos += 4; pos += 4;
@ -209,8 +208,7 @@ namespace libtorrent
{ {
error_code e; error_code e;
url = unescape_string(url, e); url = unescape_string(url, e);
if (e) continue; if (!e) p.url_seeds.push_back(url);
p.url_seeds.push_back(url);
pos = uri.find("&ws=", pos); pos = uri.find("&ws=", pos);
if (pos == std::string::npos) break; if (pos == std::string::npos) break;
pos += 4; pos += 4;

View File

@ -410,3 +410,23 @@ TORRENT_TEST(trailing_whitespace)
TEST_CHECK(h.is_valid()); TEST_CHECK(h.is_valid());
} }
TORRENT_TEST(invalid_tracker_escaping)
{
add_torrent_params p;
p.save_path = ".";
error_code ec;
parse_magnet_uri("magnet:?tr=udp%3A%2F%2Ftracker.openjnt.com%\xf7"
"A80&tr=udp%3A%2F%2Ftracker.pub.ciltbcom%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&xt=urn:btih:a38d02c287893842a39737aa866e00828aA80&xt=urn:buntu+11.04+%28Final%29"
, p, ec);
TEST_CHECK(ec);
}
TORRENT_TEST(invalid_web_seed_escaping)
{
add_torrent_params p;
p.save_path = ".";
error_code ec;
parse_magnet_uri("magnet:?ws=udp%3A%2F%2Ftracker.openjnt.com%\xf7" "A80", p, ec);
TEST_CHECK(ec);
}