File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 112.0.13
22
3+ * fix socks5 issues
34 * fix issue in loading v2 resume data merkle trees
45
562.0.12 released
Original file line number Diff line number Diff line change @@ -312,9 +312,10 @@ struct proxy_base
312312 {
313313 TORRENT_ASSERT (m_magic == 0x1337 );
314314 if (!e) return false ;
315- std::forward<Handler>(h)(e);
316315 error_code ec;
317- close (ec);
316+ // prevent lifetime management use-after-free
317+ close (ec); // close first
318+ std::move (h)(e); // consume
318319 return true ;
319320 }
320321
Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ class socks5_stream : public proxy_base
268268 int version = read_uint8 (p);
269269 int method = read_uint8 (p);
270270
271- if (version < m_version)
271+ if (version != m_version)
272272 {
273273 std::move (h)(error_code (socks_error::unsupported_version));
274274 return ;
@@ -378,7 +378,12 @@ class socks5_stream : public proxy_base
378378 else
379379 {
380380 // we either need a hostname or a valid endpoint
381- TORRENT_ASSERT (m_remote_endpoint.address () != address ());
381+ // MUST prevent malformed buf writes, endpoint corruption
382+ if (m_remote_endpoint.address () == address ())
383+ {
384+ std::move (h)(boost::asio::error::invalid_argument);
385+ return ;
386+ }
382387
383388 write_uint8 (aux::is_v4 (m_remote_endpoint) ? 1 : 4 , p); // address type
384389 write_address (m_remote_endpoint.address (), p);
@@ -448,7 +453,7 @@ class socks5_stream : public proxy_base
448453
449454 if (m_version == 5 )
450455 {
451- if (version < m_version)
456+ if (version != m_version)
452457 {
453458 std::move (h)(error_code (socks_error::unsupported_version));
454459 return ;
You can’t perform that action at this time.
0 commit comments