mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 08:13:52 +02:00
Merge bitcoin/bitcoin#28649: Do the SOCKS5 handshake reliably
af0fca530enetbase: use reliable send() during SOCKS5 handshake (Vasil Dimov)1b19d1117csock: change Sock::SendComplete() to take Span (Vasil Dimov) Pull request description: The `Socks5()` function which does the SOCKS5 handshake with the SOCKS5 proxy sends bytes to the socket without retrying partial writes. `send(2)` may write only part of the provided data and return. In this case the caller is responsible for retrying the operation with the remaining data. Change `Socks5()` to do that. There is already a method `Sock::SendComplete()` which does exactly that, so use it in `Socks5()`. A minor complication for this PR is that `Sock::SendComplete()` takes `std::string` argument whereas `Socks5()` has `std::vector<uint8_t>`. Thus the necessity for the first commit. It is possible to do also in other ways - convert the data in `Socks5()` to `std::string` or have just one `Sock::SendComplete()` that takes `void*` and change the callers to pass `str.data(), str.size()` or `vec.data(), vec.size()`. This came up while testing https://github.com/bitcoin/bitcoin/pull/27375. ACKs for top commit: achow101: ACKaf0fca530ejonatack: ACKaf0fca530epinheadmz: ACKaf0fca530eTree-SHA512: 1d4a53d0628f7607378038ac56dc3b8624ce9322b034c9547a0c3ce052eafb4b18213f258aa3b57bcb4d990a5e0548a37ec70af2bd55f6e8e6399936f1ce047a
This commit is contained in:
@@ -32,7 +32,9 @@ FUZZ_TARGET(socks5, .init = initialize_socks5)
|
||||
ProxyCredentials proxy_credentials;
|
||||
proxy_credentials.username = fuzzed_data_provider.ConsumeRandomLengthString(512);
|
||||
proxy_credentials.password = fuzzed_data_provider.ConsumeRandomLengthString(512);
|
||||
InterruptSocks5(fuzzed_data_provider.ConsumeBool());
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
g_socks5_interrupt();
|
||||
}
|
||||
// Set FUZZED_SOCKET_FAKE_LATENCY=1 to exercise recv timeout code paths. This
|
||||
// will slow down fuzzing.
|
||||
g_socks5_recv_timeout = (fuzzed_data_provider.ConsumeBool() && std::getenv("FUZZED_SOCKET_FAKE_LATENCY") != nullptr) ? 1ms : default_socks5_recv_timeout;
|
||||
|
||||
Reference in New Issue
Block a user