Skip to content

Commit 2031aa9

Browse files
committed
Merge #19562: test: Fix fuzzer compilation on macOS
c8992e8 test: Fix fuzzer compilation on macOS fixes #19557 (freenancial) Pull request description: fixes #19557 Before the fix: ``` ➜ bitcoin git:(fix-fuzzer-macos) make Making all in src CXX test/fuzz/addition_overflow-addition_overflow.o In file included from test/fuzz/addition_overflow.cpp:7: ./test/fuzz/util.h:335:13: error: no matching function for call to 'AdditionOverflow' if (AdditionOverflow((uint64_t)fuzzed_file->m_offset, random_bytes.size())) { ^~~~~~~~~~~~~~~~ ./test/fuzz/util.h:201:16: note: candidate template ignored: deduced conflicting types for parameter 'T' ('unsigned long long' vs. 'unsigned long') NODISCARD bool AdditionOverflow(const T i, const T j) noexcept ^ ./test/fuzz/util.h:346:13: error: no matching function for call to 'AdditionOverflow' if (AdditionOverflow(fuzzed_file->m_offset, n)) { ^~~~~~~~~~~~~~~~ ./test/fuzz/util.h:201:16: note: candidate template ignored: deduced conflicting types for parameter 'T' ('long long' vs. 'long') NODISCARD bool AdditionOverflow(const T i, const T j) noexcept ^ ``` After the fix: ``` ➜ bitcoin git:(fix-fuzzer-macos) ./configure --enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ --disable-asm && make clean && make -j5 ... ... CXXLD test/fuzz/uint256_deserialize Making all in doc/man make[1]: Nothing to be done for `all'. make[1]: Nothing to be done for `all-am'. ``` ACKs for top commit: fanquake: ACK c8992e8 - tested that compiling works on macOS. MarcoFalke: review ACK c8992e8 Tree-SHA512: 965cdc61b30db0e2209c91b29f0d42de927a9a5b85e1e70f22d1452e0955f876726c7a8c1d1a5f448f12bf24eec3000802071cd4ae28d8605343fd43d174ca84
2 parents 597d2f9 + c8992e8 commit 2031aa9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/test/fuzz/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class FuzzedFileProvider
332332
return 0;
333333
}
334334
std::memcpy(buf, random_bytes.data(), random_bytes.size());
335-
if (AdditionOverflow((uint64_t)fuzzed_file->m_offset, random_bytes.size())) {
335+
if (AdditionOverflow(fuzzed_file->m_offset, (int64_t)random_bytes.size())) {
336336
return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
337337
}
338338
fuzzed_file->m_offset += random_bytes.size();
@@ -343,7 +343,7 @@ class FuzzedFileProvider
343343
{
344344
FuzzedFileProvider* fuzzed_file = (FuzzedFileProvider*)cookie;
345345
const ssize_t n = fuzzed_file->m_fuzzed_data_provider.ConsumeIntegralInRange<ssize_t>(0, size);
346-
if (AdditionOverflow(fuzzed_file->m_offset, n)) {
346+
if (AdditionOverflow(fuzzed_file->m_offset, (int64_t)n)) {
347347
return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
348348
}
349349
fuzzed_file->m_offset += n;

0 commit comments

Comments
 (0)