aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-04-15 08:02:18 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-04-15 08:02:22 +0200
commit9712f75746e3da73471da2e23a4bfc1382c69308 (patch)
tree03625d8babe92925bff0519139c77c5d9e03cb40 /src/test/fuzz
parent2cd834e6c09dbbb676ecac4a36d8f0f56b4fe4b2 (diff)
parent6262182b3f1c9540291fb8de3bf7a785e7113c55 (diff)
downloadbitcoin-9712f75746e3da73471da2e23a4bfc1382c69308.tar.xz
Merge #21677: fuzz: Avoid use of low file descriptor ids (which may be in use) in FuzzedSock
6262182b3f1c9540291fb8de3bf7a785e7113c55 Avoid use of low file descriptor ids (which may be in use) in FuzzedSock and StaticContentsSock (practicalswift) Pull request description: Avoid use of low file descriptor ids (which may be in use) in `FuzzedSock`. Context: https://github.com/bitcoin/bitcoin/pull/21630/files#r610694541 ACKs for top commit: vasild: ACK 6262182b3f1c9540291fb8de3bf7a785e7113c55 Tree-SHA512: e622acb4d01446c3db01adbbbb779038be7247e13f3f4e72c614bc2880c3efd710fd3b189f87abb00f236fa5ddf91f4c215f420ca4eb08a97aaba31593254c3d
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/util.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h
index adcdd71748..a3feddc21d 100644
--- a/src/test/fuzz/util.h
+++ b/src/test/fuzz/util.h
@@ -577,15 +577,15 @@ class FuzzedSock : public Sock
public:
explicit FuzzedSock(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_data_provider{fuzzed_data_provider}
{
- m_socket = fuzzed_data_provider.ConsumeIntegral<SOCKET>();
+ m_socket = fuzzed_data_provider.ConsumeIntegralInRange<SOCKET>(INVALID_SOCKET - 1, INVALID_SOCKET);
}
~FuzzedSock() override
{
// Sock::~Sock() will be called after FuzzedSock::~FuzzedSock() and it will call
// Sock::Reset() (not FuzzedSock::Reset()!) which will call CloseSocket(m_socket).
- // Avoid closing an arbitrary file descriptor (m_socket is just a random number which
- // may concide with a real opened file descriptor).
+ // Avoid closing an arbitrary file descriptor (m_socket is just a random very high number which
+ // theoretically may concide with a real opened file descriptor).
Reset();
}