mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 15:39:05 +01:00
Merge bitcoin/bitcoin#25426: net: add new method Sock::GetSockName() that wraps getsockname() and use it in GetBindAddress()
a8d6abba5enet: change GetBindAddress() to take Sock argument (Vasil Dimov)748dbcd9f2net: add new method Sock::GetSockName() that wraps getsockname() (Vasil Dimov) Pull request description: _This is a piece of #21878, chopped off to ease review._ Wrap the syscall `getsockname()` in `Sock::GetSockName()` and change `GetBindAddress()` to take a `Sock` argument so that it can use the wrapper. This further encapsulates syscalls inside the `Sock` class and makes the callers mockable. ACKs for top commit: laanwj: Code review ACKa8d6abba5eTree-SHA512: 3a73463258c0057487fb3fd67215816b03a1c5160f45e45930eaeef86bb3611ec385794cdb08339aa074feba8ad67cd2bfd3836f6cbd40834e15d933214a05dc
This commit is contained in:
@@ -201,6 +201,20 @@ int FuzzedSock::SetSockOpt(int, int, const void*, socklen_t) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FuzzedSock::GetSockName(sockaddr* name, socklen_t* name_len) const
|
||||
{
|
||||
constexpr std::array getsockname_errnos{
|
||||
ECONNRESET,
|
||||
ENOBUFS,
|
||||
};
|
||||
if (m_fuzzed_data_provider.ConsumeBool()) {
|
||||
SetFuzzedErrNo(m_fuzzed_data_provider, getsockname_errnos);
|
||||
return -1;
|
||||
}
|
||||
*name_len = m_fuzzed_data_provider.ConsumeData(name, *name_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FuzzedSock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred) const
|
||||
{
|
||||
constexpr std::array wait_errnos{
|
||||
|
||||
Reference in New Issue
Block a user