diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 4df0813af..eda38197f 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -1562,7 +1562,7 @@ namespace libtorrent }; // the encoding policy options for use with - // settings_pack::pe_out_enc_policy and settings_pack::pe_in_enc_policy. + // settings_pack::out_enc_policy and settings_pack::in_enc_policy. enum enc_policy { // Only encrypted connections are allowed. Incoming connections that @@ -1581,7 +1581,7 @@ namespace libtorrent }; // the encryption levels, to be used with - // settings_pack::pe_allowed_enc_level. + // settings_pack::allowed_enc_level. enum enc_level { // use only plaintext encryption diff --git a/simulation/test_pe_crypto.cpp b/simulation/test_pe_crypto.cpp index cb5485258..46c97c581 100644 --- a/simulation/test_pe_crypto.cpp +++ b/simulation/test_pe_crypto.cpp @@ -74,10 +74,11 @@ void display_settings(libtorrent::settings_pack const& s) struct test_swarm_config : swarm_config { - test_swarm_config(libtorrent::settings_pack::enc_policy m_policy + test_swarm_config(libtorrent::settings_pack::enc_policy policy , libtorrent::settings_pack::enc_level level , bool prefer_rc4) : swarm_config() + , m_policy(policy) , m_level(level) , m_prefer_rc4(prefer_rc4) {} diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 311c1af8f..e26e3c780 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -304,7 +304,7 @@ namespace libtorrent p.set_bool(settings_pack::enable_dht, false); apply_settings(p); } -#endif +#endif // TORRENT_NO_DEPRECATE void session_handle::set_dht_settings(dht_settings const& settings) { @@ -648,6 +648,16 @@ namespace libtorrent void session_handle::apply_settings(settings_pack const& s) { + TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::out_enc_policy) + || s.get_int(settings_pack::out_enc_policy) + <= settings_pack::pe_disabled); + TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::in_enc_policy) + || s.get_int(settings_pack::in_enc_policy) + <= settings_pack::pe_disabled); + TORRENT_ASSERT_PRECOND(!s.has_val(settings_pack::allowed_enc_level) + || s.get_int(settings_pack::allowed_enc_level) + <= settings_pack::pe_both); + boost::shared_ptr copy = boost::make_shared(s); TORRENT_ASYNC_CALL1(apply_settings_pack, copy); } diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index ec954e60e..352913169 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -591,7 +591,7 @@ namespace libtorrent // disregard setting indices that are not string types if ((i->first & settings_pack::type_mask) != settings_pack::string_type_base) continue; - + // ignore settings that are out of bounds int index = i->first & settings_pack::index_mask; if (index < 0 || index >= settings_pack::num_string_settings)