Browse Source

Catch possible exceptions when parsing IPs. Closes #7249.

adaptive-webui-19844
sledgehammer999 7 years ago
parent
commit
31a4309077
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
  1. 42
      src/base/bittorrent/session.cpp

42
src/base/bittorrent/session.cpp

@ -1262,9 +1262,15 @@ void Session::configurePeerClasses()
, libt::address_v4::from_string("255.255.255.255") , libt::address_v4::from_string("255.255.255.255")
, 1 << libt::session::global_peer_class_id); , 1 << libt::session::global_peer_class_id);
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
f.add_rule(libt::address_v6::from_string("::0") // IPv6 may not be available on OS and the parsing
, libt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") // would result in an exception -> abnormal program termination
, 1 << libt::session::global_peer_class_id); // Affects Windows XP
try {
f.add_rule(libt::address_v6::from_string("::0")
, libt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << libt::session::global_peer_class_id);
}
catch(std::exception &) {}
#endif #endif
if (ignoreLimitsOnLAN()) { if (ignoreLimitsOnLAN()) {
// local networks // local networks
@ -1286,18 +1292,24 @@ void Session::configurePeerClasses()
, libt::address_v4::from_string("127.255.255.255") , libt::address_v4::from_string("127.255.255.255")
, 1 << libt::session::local_peer_class_id); , 1 << libt::session::local_peer_class_id);
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
// link local // IPv6 may not be available on OS and the parsing
f.add_rule(libt::address_v6::from_string("fe80::") // would result in an exception -> abnormal program termination
, libt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff") // Affects Windows XP
, 1 << libt::session::local_peer_class_id); try {
// unique local addresses // link local
f.add_rule(libt::address_v6::from_string("fc00::") f.add_rule(libt::address_v6::from_string("fe80::")
, libt::address_v6::from_string("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") , libt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << libt::session::local_peer_class_id); , 1 << libt::session::local_peer_class_id);
// loopback // unique local addresses
f.add_rule(libt::address_v6::from_string("::1") f.add_rule(libt::address_v6::from_string("fc00::")
, libt::address_v6::from_string("::1") , libt::address_v6::from_string("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << libt::session::local_peer_class_id); , 1 << libt::session::local_peer_class_id);
// loopback
f.add_rule(libt::address_v6::from_string("::1")
, libt::address_v6::from_string("::1")
, 1 << libt::session::local_peer_class_id);
}
catch(std::exception &) {}
#endif #endif
} }
m_nativeSession->set_peer_class_filter(f); m_nativeSession->set_peer_class_filter(f);

Loading…
Cancel
Save