mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-28 18:23:16 +02:00
fuzz: never return an uninitialized sockaddr in FuzzedSock::GetSockName
The fuzz provider's `ConsumeData` may return less data than necessary to fill the sockaddr struct and still return success. Fix this to avoid the caller using uninitialized memory.
This commit is contained in:
@@ -357,7 +357,9 @@ int FuzzedSock::GetSockName(sockaddr* name, socklen_t* name_len) const
|
||||
SetFuzzedErrNo(m_fuzzed_data_provider, getsockname_errnos);
|
||||
return -1;
|
||||
}
|
||||
assert(name_len);
|
||||
*name_len = m_fuzzed_data_provider.ConsumeData(name, *name_len);
|
||||
if (*name_len < (int)sizeof(sockaddr)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user