From 181d01e5fee792bfb9b9299dcc93fca985541c6b Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 22 Jul 2020 17:44:00 +0800 Subject: [PATCH] Merge #19562: test: Fix fuzzer compilation on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c8992e89594a54edf283e4916f794475070b5114 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 c8992e89594a54edf283e4916f794475070b5114 - tested that compiling works on macOS. MarcoFalke: review ACK c8992e89594a54edf283e4916f794475070b5114 Tree-SHA512: 965cdc61b30db0e2209c91b29f0d42de927a9a5b85e1e70f22d1452e0955f876726c7a8c1d1a5f448f12bf24eec3000802071cd4ae28d8605343fd43d174ca84 --- src/test/fuzz/util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 30a3580e3913cf..b2bf75b3790ddd 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -398,7 +398,7 @@ class FuzzedFileProvider return 0; } std::memcpy(buf, random_bytes.data(), random_bytes.size()); - if (AdditionOverflow(static_cast(fuzzed_file->m_offset), random_bytes.size())) { + if (AdditionOverflow(fuzzed_file->m_offset, static_cast(random_bytes.size()))) { return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1; } fuzzed_file->m_offset += random_bytes.size(); @@ -410,7 +410,7 @@ class FuzzedFileProvider FuzzedFileProvider* fuzzed_file = (FuzzedFileProvider*)cookie; SetFuzzedErrNo(fuzzed_file->m_fuzzed_data_provider); const ssize_t n = fuzzed_file->m_fuzzed_data_provider.ConsumeIntegralInRange(0, size); - if (AdditionOverflow(static_cast(fuzzed_file->m_offset), n)) { + if (AdditionOverflow(fuzzed_file->m_offset, static_cast(n))) { return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1; } fuzzed_file->m_offset += n;