mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-24 05:52:08 +02:00
Merge bitcoin/bitcoin#29774: build: Enable fuzz binary in MSVC
18fd522ca9ci, msvc: Add "Run fuzz binaries" step (Hennadii Stepanov)52933d7283fuzz: Pass `SystemRoot` environment variable to subprocess (Hennadii Stepanov)23cb8207cdci, msvc: Add "Clone fuzz corpus" step (Hennadii Stepanov)19dceddf4bbuild, msvc: Build `fuzz.exe` binary (Hennadii Stepanov)4c078d7bd2build, msvc: Enable preprocessor conformance mode (Hennadii Stepanov)09f5a74198fuzz: Re-implement `read_stdin` in portable way (Hennadii Stepanov) Pull request description: Closes https://github.com/bitcoin/bitcoin/issues/29760. Suggested in https://github.com/bitcoin/bitcoin/pull/29758#issuecomment-2025593572. ACKs for top commit: maflcko: lgtm ACK18fd522ca9🔍 sipsorcery: tACK18fd522ca9sipa: utACK18fd522ca9Tree-SHA512: 672ed6926ee9091f68f13780e77b60fc1d48731f16e847d849374f8426ffe1dafd9bcab06a27af62e8052ba345bb57f20f40579d6be8540c12ef85c23a6eec8b
This commit is contained in:
@@ -24,12 +24,14 @@ void TestAdditionOverflow(FuzzedDataProvider& fuzzed_data_provider)
|
||||
assert(is_addition_overflow_custom == AdditionOverflow(j, i));
|
||||
assert(maybe_add == CheckedAdd(j, i));
|
||||
assert(sat_add == SaturatingAdd(j, i));
|
||||
#ifndef _MSC_VER
|
||||
T result_builtin;
|
||||
const bool is_addition_overflow_builtin = __builtin_add_overflow(i, j, &result_builtin);
|
||||
assert(is_addition_overflow_custom == is_addition_overflow_builtin);
|
||||
if (!is_addition_overflow_custom) {
|
||||
assert(i + j == result_builtin);
|
||||
}
|
||||
#endif
|
||||
if (is_addition_overflow_custom) {
|
||||
assert(sat_add == std::numeric_limits<T>::min() || sat_add == std::numeric_limits<T>::max());
|
||||
} else {
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using node::SnapshotMetadata;
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -135,9 +134,9 @@ void initialize()
|
||||
#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
|
||||
static bool read_stdin(std::vector<uint8_t>& data)
|
||||
{
|
||||
uint8_t buffer[1024];
|
||||
ssize_t length = 0;
|
||||
while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) {
|
||||
std::istream::char_type buffer[1024];
|
||||
std::streamsize length;
|
||||
while ((std::cin.read(buffer, 1024), length = std::cin.gcount()) > 0) {
|
||||
data.insert(data.end(), buffer, buffer + length);
|
||||
}
|
||||
return length == 0;
|
||||
|
||||
@@ -17,12 +17,18 @@ void TestMultiplicationOverflow(FuzzedDataProvider& fuzzed_data_provider)
|
||||
const T i = fuzzed_data_provider.ConsumeIntegral<T>();
|
||||
const T j = fuzzed_data_provider.ConsumeIntegral<T>();
|
||||
const bool is_multiplication_overflow_custom = MultiplicationOverflow(i, j);
|
||||
#ifndef _MSC_VER
|
||||
T result_builtin;
|
||||
const bool is_multiplication_overflow_builtin = __builtin_mul_overflow(i, j, &result_builtin);
|
||||
assert(is_multiplication_overflow_custom == is_multiplication_overflow_builtin);
|
||||
if (!is_multiplication_overflow_custom) {
|
||||
assert(i * j == result_builtin);
|
||||
}
|
||||
#else
|
||||
if (!is_multiplication_overflow_custom) {
|
||||
(void)(i * j);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user